No Launcher activity found, despite being declared in manifest.xml

烂漫一生 提交于 2019-12-06 02:29:50

问题


In my app I have the main activity defined in the manifest.xml file like this:

<activity
            android:name=".MainActivity"
            android:label="@string/guide_activity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.MAIN" />

                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable"/>
        </activity>

when I run the project from eclipse connected to a real device or an emulator I receive the following message in the console: No Launcher activity found

what can be the reason of this ?


回答1:


Split the intent-filter into two seperate ones. If you mix them like this, android won't determine that one of the two is the launcher filter.

<activity
    android:name=".MainActivity"
    android:label="@string/guide_activity" >

        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.SEARCH" />
        </intent-filter>

        <meta-data android:name="android.app.searchable"
               android:resource="@xml/searchable"/>
</activity>


来源:https://stackoverflow.com/questions/9259315/no-launcher-activity-found-despite-being-declared-in-manifest-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!