刚刚接手安卓,环境搭建完了之后,按照书上新建的helloword程序,但是在运行的时候,虚拟机光能调用,不显示“helloworld”。下面错误提示是 。在网上找了好多答案,包括删除R.java文件,重启程序,删除buildpath的库文件都解决不了问题。请高手们帮忙回答一下吧。
 程序如下:
 package helloword.a;
 
import android.app.Activity;
 import android.os.Bundle;
 import android.widget.TextView;
 public class HellowordActivity extends Activity {
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
         TextView tv = new TextView(this);
         tv.setText("Hello World");
         setContentView(tv);
     }
 }
 Console显示:
 [2012-09-21 18:52:08 - helloword] ------------------------------
 [2012-09-21 18:52:08 - helloword] Android Launch!
 [2012-09-21 18:52:08 - helloword] adb is running normally.
 [2012-09-21 18:52:08 - helloword] Performing helloword.a.HellowordActivity activity launch
 [2012-09-21 18:52:08 - helloword] Automatic Target Mode: Preferred AVD '2.3.1' is not available. Launching new emulator.
 [2012-09-21 18:52:08 - helloword] Launching a new emulator with Virtual Device '2.3.1'
 [2012-09-21 18:52:10 - helloword] New emulator found: emulator-5554
 [2012-09-21 18:52:10 - helloword] Waiting for HOME ('android.process.acore') to be launched...
 [2012-09-21 18:52:53 - helloword] HOME is up on device 'emulator-5554'
 [2012-09-21 18:52:53 - helloword] Uploading helloword.apk onto device 'emulator-5554'
 [2012-09-21 18:52:53 - helloword] Installing helloword.apk...
 [2012-09-21 18:53:26 - helloword] Installation failed due to invalid APK file!
 [2012-09-21 18:53:26 - helloword] Please check logcat output for more details.
 [2012-09-21 18:53:26 - helloword] Launch canceled!
 
因为没有基础,希望回答的能详细点。谢谢

解决方案 »

  1.   

     [2012-09-21 18:53:26 - helloword] Installation failed due to invalid APK file!
    根本安装不了,你重新建一个模拟器试试?
    看看是什么报错,贴上来,
      

  2.   

    先把TextView放在main.xml中,看看能不能显示hello world。
      

  3.   

    看下应该是没问题的,运行了下也是对的
    但是楼主:
     "
      setContentView(R.layout.main);
       TextView tv = new TextView(this);
       tv.setText("Hello World");
       setContentView(tv);
     "
    这个写法是没错,建议不要这么搞 养成好习惯么