这是我的 MyTasteActivity 代码:
package MyTaste;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MyTasteActivity 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);
}
}
这是我的 XML Android 清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="My.Taste.App"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyTaasteActivity"
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>
</manifest>
那么为什么我不断收到此错误:
06-14 20:22:48.779: E/AndroidRuntime(749): FATAL EXCEPTION: main
06-14 20:22:48.779: E/AndroidRuntime(749): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{My.Taste.App/My.Taste.App.MyTasteActivity}: java.lang.ClassNotFoundException: My.Taste.App.MyTasteActivity
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-14 20:22:48.779: E/AndroidRuntime(749): at
android.os.Handler.dispatchMessage(Handler.java:99)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.os.Looper.loop(Looper.java:137)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-14 20:22:48.779: E/AndroidRuntime(749): at java.lang.reflect.Method.invokeNative(Native Method)
06-14 20:22:48.779: E/AndroidRuntime(749): at java.lang.reflect.Method.invoke(Method.java:511)
06-14 20:22:48.779: E/AndroidRuntime(749): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-14 20:22:48.779: E/AndroidRuntime(749): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-14 20:22:48.779: E/AndroidRuntime(749): at dalvik.system.NativeStart.main(Native Method)
06-14 20:22:48.779: E/AndroidRuntime(749): Caused by: java.lang.ClassNotFoundException: My.Taste.App.MyTasteActivity
06-14 20:22:48.779: E/AndroidRuntime(749): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-14 20:22:48.779: E/AndroidRuntime(749): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-14 20:22:48.779: E/AndroidRuntime(749): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
06-14 20:22:48.779: E/AndroidRuntime(749): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
06-14 20:22:48.779: E/AndroidRuntime(749): ... 11 more
AVD 将显示消息“不幸的是,MyTaste 已停止”。我不知道出了什么问题,我已经重新安装了几次 Android SDK。