我正在尝试在windows64上设置一个eclipse环境。我想我已经完成了教程中的所有工作(developer.android.com),但是当我在eclipse中选择要运行的项目时,我让模拟器弹出,但它没有显示hello world。
我尝试了android版本2.1,模拟器弹出,最终在显示ANDROID之后出现了黑屏……
我尝试使用4.0.3,在模拟器弹出后,我只看到了一个平面简安卓手机界面,它不能运行我的应用程序。代码如下。有人知道我错过了什么吗?
当我运行仿真器时,Eclipse显示以下内容
[2012-02-19 11:58:40 - trst] ------------------------------
[2012-02-19 11:58:40 - trst] Android Launch!
[2012-02-19 11:58:40 - trst] adb is running normally.
[2012-02-19 11:58:40 - trst] Performing com.example.helloandroid.TrstActivity activity launch
[2012-02-19 11:58:40 - trst] Automatic Target Mode: launching new emulator with compatible AVD 'interface'
[2012-02-19 11:58:40 - trst] Launching a new emulator with Virtual Device 'interface'
[2012-02-19 11:58:55 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error
[2012-02-19 11:58:55 - trst] New emulator found: emulator-5554
[2012-02-19 11:58:55 - trst] Waiting for HOME ('android.process.acore') to be launched...代码:
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class TrstActivity 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);
}
}发布于 2012-06-19 19:09:47
我只想补充说,我看到了Android屏幕,但它至少在2分钟内什么也没做,我以为我的应用程序也崩溃了。但实际上我认为这只是虚拟设备启动。
两三分钟后,Android的日志被一个登录/闪屏所取代--当我点击解锁...我终于看到了我的"hello world“消息...多解脱啊!
发布于 2012-02-20 01:35:00
显而易见的解决方案可能是尝试单击仿真器的后退按钮。(因为我在您的代码中找不到任何其他错误)
此外,请粘贴Logcat,以便我们可以确定确切的原因。
发布于 2012-02-20 01:38:40
console在日志中有没有告诉你为什么它不能运行?我从来没有像那样使用过setContentView(int)。我一直将它与类似R.layout.hello (或这里的任何东西)的布局一起使用,然后您可以像这样引用TextView
TextView mTextView = findViewById(R.id.myTextView);
mTextView.setText("Hello, Android!");希望这能有所帮助。
https://stackoverflow.com/questions/9351380
复制相似问题