Android应用程序不能在仿真器上运行

问题描述:

我正在尝试使用Eclipse运行Hello World教程代码。我已经设置了AVD,但是当我尝试运行代码时,模拟器会加载到主屏幕,并且应用程序不会显示。在控制台中没有显示错误,并且logcat完全是空的(我也让它运行了30分钟)。Android应用程序不能在仿真器上运行

控制台输出:

[2011-09-28 18:00:31 - AndroidTest] ------------------------------ 
[2011-09-28 18:00:31 - AndroidTest] Android Launch! 
[2011-09-28 18:00:31 - AndroidTest] adb is running normally. 
[2011-09-28 18:00:31 - AndroidTest] Performing com.example.helloandroid.AndroidTest activity launch 
[2011-09-28 18:00:31 - AndroidTest] Automatic Target Mode: launching new emulator with compatible AVD 'myAVD' 
[2011-09-28 18:00:31 - AndroidTest] Launching a new emulator with Virtual Device 'myAVD' 

代码:

package com.example.helloandroid; 

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

public class AndroidTest 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 World!"); 
     setContentView(tv); 
    } 
} 

我在Windows 7上运行64位。

谢谢。

+0

你有一个完整的清单文件? – cjk

+0

尝试重新运行应用程序,一旦主屏幕可见(并且您解锁了键锁)。如果一个模拟器正在运行,你的应用程序将被部署到它而不是启动一个新的。 – 2011-09-28 18:07:59

我认为你需要创建一个快速布局,并将内容设置为布局。在你的/布局文件夹 创建此home.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_layout" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <TextView 
     android:id="@+id/my_text_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World" 
     android:textSize="24sp" 
     /> 
</LinearLayout> 

在的onCreate,为此

super.onCreate(savedInstanceState); 
setContentView(R.layout.home); 

这应该工作,

后来,你可以参考你的TextView并将其文本更改...

让我们知道它是怎么回事。

-serkan

解锁模拟器和重新部署应用到它。