不幸的是,My First App已停止在模拟器中

时间:2012-12-18 19:12:59

标签: java android

我正在Android官方网站上尝试第一个教程。这是为了在点击发送时展示一条消息,但是当我点击发送时我得到一个错误。

我已尝试过这些问题,但我无法找到问题的答案

我对Java和Android缺乏经验。

错误日志:

12-18 18:56:33.421: W/Trace(1004): Unexpected value from nativeGetEnabledTags: 0
12-18 18:56:33.421: W/Trace(1004): Unexpected value from nativeGetEnabledTags: 0
12-18 18:56:33.450: W/Trace(1004): Unexpected value from nativeGetEnabledTags: 0
12-18 18:56:33.480: D/AndroidRuntime(1004): Shutting down VM
12-18 18:56:33.490: W/dalvikvm(1004): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
12-18 18:56:33.520: E/AndroidRuntime(1004): FATAL EXCEPTION: main
12-18 18:56:33.520: E/AndroidRuntime(1004): java.lang.IllegalStateException: Could not execute method of the activity
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.view.View$1.onClick(View.java:3597)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.view.View.performClick(View.java:4202)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.view.View$PerformClick.run(View.java:17340)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.os.Handler.handleCallback(Handler.java:725)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.os.Looper.loop(Looper.java:137)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.ActivityThread.main(ActivityThread.java:5039)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at java.lang.reflect.Method.invokeNative(Native Method)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at java.lang.reflect.Method.invoke(Method.java:511)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at dalvik.system.NativeStart.main(Native Method)
12-18 18:56:33.520: E/AndroidRuntime(1004): Caused by: java.lang.reflect.InvocationTargetException
12-18 18:56:33.520: E/AndroidRuntime(1004):     at java.lang.reflect.Method.invokeNative(Native Method)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at java.lang.reflect.Method.invoke(Method.java:511)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.view.View$1.onClick(View.java:3592)
12-18 18:56:33.520: E/AndroidRuntime(1004):     ... 11 more
12-18 18:56:33.520: E/AndroidRuntime(1004): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Activity.startActivityForResult(Activity.java:3370)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Activity.startActivityForResult(Activity.java:3331)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Activity.startActivity(Activity.java:3566)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at android.app.Activity.startActivity(Activity.java:3534)
12-18 18:56:33.520: E/AndroidRuntime(1004):     at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:37)
12-18 18:56:33.520: E/AndroidRuntime(1004):     ... 14 more
12-18 18:56:37.129: I/Process(1004): Sending signal. PID: 1004 SIG: 9

1 个答案:

答案 0 :(得分:5)

  

无法找到显式活动类   {com.example.myfirstapp / com.example.myfirstapp.DisplayMessageActivity};   你有没有在AndroidManifest.xml中声明这个活动?

因此请确保您已在DisplayMessageActivity中声明AndroidManifest为:

<activity 
   android:name="com.example.myfirstapp.DisplayMessageActivity">
</activity>