Android studio在清单文件中更改后无法识别默认活动

时间:2018-03-23 14:02:15

标签: android android-manifest

我是一个Android应用,其中LoginActivity是主要活动。我创建了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。但它并没有认识到这是默认活动。我该如何解决?

1 个答案:

答案 0 :(得分:4)

这应该是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>