0

我只是在学习Android开发。我在 Eclipse 中创建了一个新的 Android 应用程序项目,它创建了一个基本的 hello world。Eclipse 会启动 AVD,但不会启动 HelloWorld 应用程序。它设法启动了一次应用程序。我将尝试提供有关我的设置的尽可能多的信息。任何建议将不胜感激。

  • Windows 7 家庭高级版 64 位
  • 已安装 JDK 7u5 64 位
  • 面向 Java 开发人员的 Eclipse IDE 64 位
  • 已安装 Android ADT
  • 已安装 Android SDK
    • 安卓 2.3.3 (API10)

当我创建一个新的 Android 应用程序项目时,我选择了 Build SDK:Android 2.3.3 (API10)和 Minimum Required SDK: API10: Android 2.3.3 (Gingerbread)

MainActivity.java

package com.mytest.helloworld;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我有一个使用Android 2.3.3 - API Level 10皮肤目标的 AVD Default (WVGA800)。没有自定义属性。

MainActivity.java作为 Android 应用程序启动,AVD 启动,但 HelloWorld 应用程序没有。这是 Eclipse Android 控制台输出:

[2012-07-22 02:11:22 - HelloWorld] ------------------------------
[2012-07-22 02:11:22 - HelloWorld] Android Launch!
[2012-07-22 02:11:22 - HelloWorld] adb is running normally.
[2012-07-22 02:11:22 - HelloWorld] Performing com.mytest.helloworld.MainActivity activity launch
[2012-07-22 02:11:22 - HelloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'Android_2.3.3'
[2012-07-22 02:11:22 - HelloWorld] Launching a new emulator with Virtual Device 'Android_2.3.3'

这是我设法让它工作时的控制台输出:

[2012-07-21 15:51:57 - HelloWorld] ------------------------------
[2012-07-21 15:51:57 - HelloWorld] Android Launch!
[2012-07-21 15:51:57 - HelloWorld] adb is running normally.
[2012-07-21 15:51:57 - HelloWorld] Performing com.mytest.helloworld.MainActivity activity launch
[2012-07-21 15:51:57 - HelloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'Android_2.3.3'
[2012-07-21 15:51:57 - HelloWorld] Launching a new emulator with Virtual Device 'Android_2.3.3'
[2012-07-21 15:51:58 - HelloWorld] New emulator found: emulator-5554
[2012-07-21 15:51:58 - HelloWorld] Waiting for HOME ('android.process.acore') to be launched...
[2012-07-21 15:52:06 - HelloWorld] HOME is up on device 'emulator-5554'
[2012-07-21 15:52:06 - HelloWorld] Uploading HelloWorld.apk onto device 'emulator-5554'
[2012-07-21 15:52:08 - HelloWorld] Installing HelloWorld.apk...
[2012-07-21 15:52:12 - HelloWorld] Success!
[2012-07-21 15:52:12 - HelloWorld] Starting activity com.mytest.helloworld.MainActivity on device emulator-5554
[2012-07-21 15:52:13 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mytest.helloworld/.MainActivity }

请记住,当我创建这个 Hello World 时,我没有编辑任何内容。我唯一输入的是项目的名称。

4

2 回答 2

0

当我运行时,adb devices我没有看到我的 AVD 设备列出。看来我需要通过运行重新启动 adb 服务器:

adb kill-server adb start-server

我又跑adb devices了,看到我的 AVD 设备列出来了。我的 HelloWorld 应用程序终于运行了。

于 2012-07-25T03:56:03.110 回答
0

启动模拟器需要时间。然后它将启动您的应用程序。

不要每次都关闭模拟器,启动一次,然后只选择这个来运行你的应用程序......

于 2012-07-22T06:25:52.123 回答