Android 在清单文件中更改默认值后,工作室无法识别默认值 activity
Android studio unable to recognize default activity after changing it in manifest file
我有一个 android 应用程序,其中 LoginActivity
是主要 activity。我创建了一个 SplashScreen
活动,然后更改 AndroidManifest
如下所示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dell.inventoryplay">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".InventoryPlayApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.dell.inventoryplay.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name=".main.SplashActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".main.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity
android:name=".main.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/DellThemeFullscreen" />
<receiver
android:name=".alarm.AlarmReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.NOTIFY" />
</intent-filter>
</receiver>
<receiver
android:name=".alarm.BootReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name=".AirWatchSDKContextService"/>
<service android:name=".AirWatchSDKIntentService"/>
</application>
</manifest>
当我尝试 运行 修改 android 应用程序时,它显示如下错误:
Error running app: Default activity not found.
我已经添加了
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
到SplashActivity
。但它没有将其识别为默认 activity。我该如何解决?
这应该是 category
而不是 action
所以使用这个
<category android:name="android.intent.category.LAUNCHER"/>
而不是
<action android:name="android.intent.category.LAUNCHER"/>
<activity
android:name=".main.SplashActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
我有一个 android 应用程序,其中 LoginActivity
是主要 activity。我创建了一个 SplashScreen
活动,然后更改 AndroidManifest
如下所示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dell.inventoryplay">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".InventoryPlayApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.dell.inventoryplay.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name=".main.SplashActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".main.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity
android:name=".main.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/DellThemeFullscreen" />
<receiver
android:name=".alarm.AlarmReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.NOTIFY" />
</intent-filter>
</receiver>
<receiver
android:name=".alarm.BootReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name=".AirWatchSDKContextService"/>
<service android:name=".AirWatchSDKIntentService"/>
</application>
</manifest>
当我尝试 运行 修改 android 应用程序时,它显示如下错误:
Error running app: Default activity not found.
我已经添加了
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
到SplashActivity
。但它没有将其识别为默认 activity。我该如何解决?
这应该是 category
而不是 action
所以使用这个
<category android:name="android.intent.category.LAUNCHER"/>
而不是
<action android:name="android.intent.category.LAUNCHER"/>
<activity
android:name=".main.SplashActivity"
android:configChanges="orientation|screenSize"
android:exported="false"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/DellTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>