Java 运行Android Emulator时出错

Java 运行Android Emulator时出错,java,android,emulation,Java,Android,Emulation,这是我学习使用的第一个Android应用程序,运行模拟器时出现错误 节目如下: package com.thenewboston.android.sarabjeet; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActi

这是我学习使用的第一个Android应用程序,运行模拟器时出现错误

节目如下:

package com.thenewboston.android.sarabjeet;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */

    int counter;
    Button add, sub;
    TextView display;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        counter = 0;
        add = (Button) findViewById(R.id.bAdd);
        sub = (Button) findViewById(R.id.bSubtract);
        display = (TextView) findViewById(R.id.tvDisplay);
        add.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter++;
                display.setText("Your total is " + counter);
            }
        });
        sub.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                counter--;
                display.setText("Your total is " + counter);
            }
        });
    }
}
下面是运行时信息和错误:

[2011-10-12 18:16:57 - sarabjeet] Android Launch!
[2011-10-12 18:16:57 - sarabjeet] adb is running normally.
[2011-10-12 18:16:57 - sarabjeet] Performing com.thenewboston.android.sarabjeet.MainActivity activity launch
[2011-10-12 18:16:57 - sarabjeet] Automatic Target Mode: Preferred AVD 'Sarabjeets_Phone' is available on emulator 'emulator-5554'
[2011-10-12 18:17:00 - sarabjeet] Application already deployed. No need to reinstall.
[2011-10-12 18:17:00 - sarabjeet] Starting activity com.thenewboston.android.sarabjeet.MainActivity on device emulator-5554
[2011-10-12 18:17:02 - sarabjeet] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.thenewboston.android.sarabjeet/.MainActivity }
[2011-10-12 18:17:02 - sarabjeet] **ActivityManager: Warning: Activity not started, its current task has been brought to the front**
我对Android编程和运行模拟器是完全陌生的。这里可能有什么问题,我没有看到我应该看到的模拟器

非常感谢

Warning: Activity not started, its current task has been brought to the front
这是因为您的应用程序已经在模拟器中运行,请按“上一步”按钮,然后再次运行并尝试或转到“设置第一次删除应用程序并重新安装”


这是因为您的应用程序已经在模拟器中运行,请按“上一步”按钮,然后再次运行并尝试或转到“设置第一次删除应用程序并重新安装”。

这不是错误。这些工具只是看到您的程序中没有任何更改,所以它们没有将您的应用程序重新编译到新的APK中。他们在模拟器上启动了已经安装的一个


有时工具会忽略您更改的资源(例如
/res
文件夹中的图像文件),在这种情况下,您可以清理项目以强制重新生成。在eclipse中使用
Project->Clean..

这不是一个错误。这些工具只是看到您的程序中没有任何更改,所以它们没有将您的应用程序重新编译到新的APK中。他们在模拟器上启动了已经安装的一个


有时工具会忽略您更改的资源(例如
/res
文件夹中的图像文件),在这种情况下,您可以清理项目以强制重新生成。在eclipse中使用
Project->Clean..

检查com.thenewboston.android.sarabjeet 确保它在您的清单文件中 可能是这样的

<activity android:name="sarabjeet.MainActivity"></activity>

或者不管你的包叫什么:)

如果所有其他操作都失败,则从模拟器中删除应用程序,然后关闭模拟器

按项目>清理>清理所有项目

然后再次加载模拟器,一切都会好起来

看起来可能是这样


也给我发你的android清单:)

检查com.thenewboston.android.sarabjeet 确保它在您的清单文件中 可能是这样的

<activity android:name="sarabjeet.MainActivity"></activity>

或者不管你的包叫什么:)

如果所有其他操作都失败,则从模拟器中删除应用程序,然后关闭模拟器

按项目>清理>清理所有项目

然后再次加载模拟器,一切都会好起来

看起来可能是这样


也将您的android清单位发布给我:)

您程序中的真正错误将只打印在logcat中。阅读本文了解如何显示logcat内容:程序中的真正错误将仅打印在logcat中。阅读本节了解如何显示logcat内容: