android - 即使代码正常,也找不到启动器 Activity (尽管我不确定)

标签 android eclipse error-handling app-launcher

我现在正在尝试使用Eclipse和推荐的ADK开发一个简单的Android应用程序。我确信开发工具已经非常更新。但是,当我尝试编写一个简单的Hello World应用程序并在创建的模拟器中运行它时,我永远也不会摆脱找不到启动器的 Activity 。我已经检查了Android list ,并且确定启动器 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'!

最佳答案

那么logcat是正确的,<activity>没有启动器<application>。将 Activity 标签移到 list 文件中的应用程序标签内

<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>

关于android - 即使代码正常,也找不到启动器 Activity (尽管我不确定),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24724404/

相关文章:

html - play1.2.4框架html中无法显示错误信息

java - React Native(Android 原生模块): Get access to ReactContext in another Class?

eclipse - 自定义 Mylyn 上下文 UI?

java - 我想将 Eclipse 控制台日志保存到字符串中

javascript - 在 fetch() 函数中捕获错误

java - Java BMI计算器问题-英制或公制用户输入,错误处理,正确值输入,转换

java - 以编程方式创建图层列表

java - 为什么我可以在一个应用程序中看到我的网站,但在另一应用程序中却看不到?

android - 在不缩放内部内容的情况下缩放 Android ListView

eclipse - 无法在 Eclipse 中运行 Kotlin 应用程序