我正在测试一个简单的 hello 应用程序,但它没有在模拟器上启动。没有错误,控制台是这样的:
[2010-11-16 21:26:06 - Hello World] ------------------------------
[2010-11-16 21:26:06 - Hello World] Android Launch!
[2010-11-16 21:26:06 - Hello World] adb is running normally.
[2010-11-16 21:26:06 - Hello World] Performing com.hello.HelloWorld.HelloWorld activity launch
[2010-11-16 21:26:09 - Hello World] Launching a new emulator with Virtual Device 'VirtualDevice2.2'
模拟器启动,屏幕出现锁,但我的应用程序无法启动。
尝试解锁并转到启动器查找我的应用程序,但它不在那里。
任何人都可以帮助我解决这个问题吗?
Thanks.
Code:
package com.hello.HelloWorld;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// We want to view some very simple text, so we need a TextView
TextView tv = new TextView(this);
// Put some text to the newly created TextVIew
tv.setText("Hello Android");
// Tell our App to display the textView
this.setContentView(tv);
}
}
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.hello.HelloWorld">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloWorld"
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>
<uses-sdk android:minSdkVersion="8" />
</manifest>
我猜您正在 Windows 7 或 Vista 上进行开发。无论哪种情况,您的主机文件都会将“localhost”映射到“::1”。 Android(从 2.2 开始)不能很好地处理 IPv6,因此您会在日志中进一步发现“协议绑定”失败(不是 logcat 内容,DDMS IIRC)。
要解决此问题,您需要将 localhost 的定义更改为“127.0.0.1”。 c:\windows\system32\drivers\etc\hosts。将“::1”更改为“127.0.0.1”。 IIRC,你必须另存为一个不同的名称,删除原来的名称,然后重命名回“hosts”,不带扩展名。
或者您可以使用没有自制 USB 驱动程序的 HTC 设备。查看适用于您操作系统的“HTC Synch”应用程序的 HTC 支持页面。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)