【问题标题】:no launcher activity found even when the code is alright (though i'm not sure)即使代码没问题,也没有发现启动器活动(虽然我不确定)
【发布时间】:2014-09-03 15:41:08
【问题描述】:

我现在正在尝试使用 Eclipse 和推荐的 ADK 开发一个简单的 Android 应用程序。我确信开发工具非常更新。但是,当我尝试编写一个简单的 Hello World 应用程序并在创建的模拟器中运行它时,我永远无法摆脱找不到启动器的活动。我已经检查了 Android 清单,并且我确定 Launcher Activity 已经创建。代码如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
        <activity
        android:name="com.example.helloworld.Activity_1"
        android:label="@string/app_name"
        >
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>
</application>

</manifest>

返回:

[2014-07-16 19:24:02 - HelloWorld] Android Launch!
[2014-07-16 19:24:02 - HelloWorld] adb is running normally.
[2014-07-16 19:24:02 - HelloWorld] No Launcher activity found!
[2014-07-16 19:24:02 - HelloWorld] The launch will only sync the application package on the device!
[2014-07-16 19:24:02 - HelloWorld] Performing sync
[2014-07-16 19:24:02 - HelloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'AVD'
[2014-07-16 19:24:02 - HelloWorld] Launching a new emulator with Virtual Device 'AVD'
[2014-07-16 19:24:17 - Emulator] emulator: device fd:612
[2014-07-16 19:24:17 - Emulator] 
[2014-07-16 19:24:17 - Emulator] HAX is working and emulator runs in fast virt mode
[2014-07-16 19:24:27 - Emulator] emulator: warning: opening audio input failed
[2014-07-16 19:24:27 - Emulator] 
[2014-07-16 19:24:27 - HelloWorld] New emulator found: emulator-5554
[2014-07-16 19:24:27 - HelloWorld] Waiting for HOME ('android.process.acore') to be launched...

我知道可能会有很多这样的问题。我遵循了许多答案和教程,但仍然无法摆脱这个错误。谁能帮帮我?


改进的新代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
            <activity
            android:name="com.example.helloworld.MainActivity"
            android:label="@string/app_name"
            >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
               </intent-filter>
            </activity>
            <activity
            android:name="com.example.helloworld.DisplayMessageActivity"
            android:label="@string/title_activity_display_message"
            android:parentActivityName="com.example.helloworld.MainActivity" >
            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.myfirstapp.MainActivity" />
    </activity>
    </application>

</manifest>

返回:

[2014-07-16 19:34:00 - HelloWorld] Android Launch!
[2014-07-16 19:34:00 - HelloWorld] adb is running normally.
[2014-07-16 19:34:00 - HelloWorld] No Launcher activity found!
[2014-07-16 19:34:00 - HelloWorld] The launch will only sync the application package on the device!
[2014-07-16 19:34:00 - HelloWorld] Performing sync
[2014-07-16 19:34:01 - HelloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'AVD'
[2014-07-16 19:34:01 - HelloWorld] Launching a new emulator with Virtual Device 'AVD'
[2014-07-16 19:34:21 - Emulator] emulator: device fd:612
[2014-07-16 19:34:21 - Emulator] 
[2014-07-16 19:34:21 - Emulator] HAX is working and emulator runs in fast virt mode
[2014-07-16 19:34:23 - Emulator] emulator: warning: opening audio input failed
[2014-07-16 19:34:23 - Emulator] 
[2014-07-16 19:34:26 - HelloWorld] New emulator found: emulator-5554
[2014-07-16 19:34:26 - HelloWorld] Waiting for HOME ('android.process.acore') to be launched...
[2014-07-16 19:36:08 - HelloWorld] emulator-5554 disconnected! Cancelling 'sync'!

【问题讨论】:

  • 发布您的应用程序清单。
  • 查看示例应用程序,您会在清单中找到activity 标记。这就是您的情况所缺少的。
  • @RichardLeMesurier 活动标签已添加,但问题仍然存在
  • @hichris123 什么是应用程序清单?这是 Android 清单,我不确定它是否是您想要的。
  • 尝试以下步骤:1) 尝试 clean & build,2) 从模板创建一个空白的 HelloWorld 应用程序,并确保其正常工作,3) 将代码从损坏的项目复制到新的工作项目中。跨度>

标签: android eclipse error-handling app-launcher


【解决方案1】:

好吧,logcat 是正确的,&lt;application&gt; 没有启动器&lt;activity&gt;。在清单文件的应用程序标签内移动活动标签

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.helloworld"
  android:versionCode="1"
  android:versionName="1.0" >



<uses-sdk
  android:minSdkVersion="8"
  android:targetSdkVersion="21" />

<application
  android:allowBackup="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name"
  android:theme="@style/AppTheme" >
  <activity
     android:name="com.example.helloworld.Activity_1"
     android:label="@string/app_name">
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
</application>

【讨论】:

  • 感谢@Pr38y,但我仍然无法根据您的建议解决问题... :(
猜你喜欢
  • 2017-04-24
  • 1970-01-01
  • 1970-01-01
  • 2020-02-05
  • 2015-04-17
  • 1970-01-01
  • 2020-09-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多