1. No Launcher activity found!
今天启动Android App时, 出现以下错误:
[2013-06-02 22:55:50 - Demo1] No Launcher activity found!
[2013-06-02 22:55:50 - Demo1] The launch will only sync the application package on the device!
原因是: 在 AndroidManifest.xml没有加:
- <intent-filter>
- <category android:name="android.intent.category.LAUNCHER" />
- <action android:name="android.intent.action.MAIN" />
- lt;/intent-filter>
所以启动器找不到要启动的Activity。
-----------------------------------------------------------------------------------
修改前的 AndroidManifest.xml:
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.test.test"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk
- android:minSdkVersion="11"
- android:targetSdkVersion="17" />
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity android:name="com.test.sudoku.Sudoku" >
- </activity>
- </application>
- </manifest>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.test.test"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk
- android:minSdkVersion="11"
- android:targetSdkVersion="17" />
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity android:name="com.test.sudoku.Sudoku" >
- <strong><intent-filter>
- <category android:name="android.intent.category.LAUNCHER" />
- <action android:name="android.intent.action.MAIN" />
- </intent-filter></strong>
- </activity>
- </application>
- </manifest>
2. AndroidManifest.xml 中 R 与Activity的 Package
AndroidManifest.xml中指定资源文件类R所在的地方:
- <span style="white-space:pre"> </span><manifest xmlns:android="http://schemas.android.com/apk/res/android"
- <span style="white-space:pre"> </span> package="com.test.test"
与 Activity的name的前缀的关系:
- <span style="white-space:pre"> </span><activity android:name="com.test.sudoku.Sudoku" >
如果资源类 R 的package与 Activity的package 一样,那么,我们可以将Activity的name写成下面的样子;否则就必须将Activity的pack名加上,写成上面的样子:
- <span style="white-space:pre"> </span><activity android:name=".Sudoku" >
参考网页:
http://stackoverflow.com/questions/14955993/no-launcher-activity-found