eclipse Android 应用程序未在模拟器上启动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6203581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:22:58  来源:igfitidea点击:

Android app not launching on emulator

androideclipseemulation

提问by user779608

I just set up eclipse to start android development according to this http://developer.android.com/sdk/installing.html. My problem seems similar to this one: Android app not launching on emulator, but the solution will not work. I am trying to run a simple hello app. I do not get any errors but here is the console:

我只是根据这个http://developer.android.com/sdk/installing.html设置了 eclipse 来开始 android 开发。我的问题似乎与此类似:Android 应用程序未在 模拟器 上启动,但该解决方案不起作用。我正在尝试运行一个简单的 hello 应用程序。我没有收到任何错误,但这是控制台:

[2011-06-01 10:03:53 - HelloAndroid] ------------------------------
[2011-06-01 10:03:53 - HelloAndroid] Android Launch!
[2011-06-01 10:03:53 - HelloAndroid] adb is running normally.
[2011-06-01 10:03:53 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch
[2011-06-01 10:04:00 - HelloAndroid] Launching a new emulator with Virtual Device 'AVD2.2'

Here is the little code that I have:

这是我拥有的小代码:

package com.example.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
   }
}

Here is the manifest:

这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.helloandroid"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloAndroid"
                  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>

The emulator launches and goes to a screen where I can unlock it. The emulator seems to work but the app is never launched. Also when I have the emulator running and I go and try to relaunch the app by clicking run as... Android application and a pop up box asks me to choose an emulator to launch, the running emulator is not shown.

模拟器启动并进入一个我可以解锁它的屏幕。模拟器似乎可以工作,但该应用程序从未启动。此外,当我运行模拟器并尝试通过单击运行方式重新启动应用程序... Android 应用程序和弹出框要求我选择要启动的模拟器时,未显示正在运行的模拟器。

回答by Aleadam

Try adding

尝试添加

<category android:name="android.intent.category.DEFAULT" />

Eclipse by default launches the DEFAULT activity. If that does not work, right click on the project, and check the run configurations. You have an option to set which activity to launch.

Eclipse 默认启动 DEFAULT 活动。如果这不起作用,请右键单击该项目,然后检查运行配置。您可以选择设置要启动的活动。

Also, you should be able to see the icon for your app in the applications drawer on the emulator launcher. Click on that icon and see if the app launches. If it does not, then the problem is in your activity somehow (although I did not see anything wrong in it).

此外,您应该能够在模拟器启动器的应用程序抽屉中看到您的应用程序的图标。单击该图标并查看应用程序是否启动。如果没有,那么问题出在您的活动中(尽管我没有发现其中有任何问题)。

If those two do not work, try restarting adb from the command prompt:

如果这两个不起作用,请尝试从命令提示符重新启动 adb:

>adb kill-server
>adb start-server

回答by Gangnus

Sometimes in the similar situation clearing the project helped...

有时在类似的情况下,清理项目有助于...

Have you set the appname in the strings.xml file?

您是否在 strings.xml 文件中设置了 appname?