1

我有一个简单的应用程序,您可以在 textview 中输入文本并按提交,它会在另一个 Activity 中显示文本。但是,当我按下提交时,给我消息“不幸地发送已停止”我查看了 SO 上的其他线程,但不幸的是 myfirstproject stop working 错误在 java似乎最接近,他们说检查 LogCat 文件,它想出了不止一个错误:

07-11 19:38:01.925: E/Trace(729): error opening trace file: No such file or directory (2)
07-11 19:38:05.815: I/Choreographer(729): Skipped 451 frames!  The application may be doing too much work on its main thread.
07-11 19:38:06.009: D/gralloc_goldfish(729): Emulator without GPU emulation detected.
07-11 19:38:35.046: I/Choreographer(729): Skipped 45 frames!  The application may be doing too much work on its main thread.
07-11 19:38:41.427: D/AndroidRuntime(729): Shutting down VM
07-11 19:38:41.435: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-11 19:38:41.585: E/AndroidRuntime(729): FATAL EXCEPTION: main
07-11 19:38:41.585: E/AndroidRuntime(729): java.lang.IllegalStateException: Could not execute method of the activity
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.view.View$1.onClick(View.java:3591)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.view.View.performClick(View.java:4084)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.view.View$PerformClick.run(View.java:16966)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.os.Handler.handleCallback(Handler.java:615)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.os.Looper.loop(Looper.java:137)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.ActivityThread.main(ActivityThread.java:4745)
07-11 19:38:41.585: E/AndroidRuntime(729):  at java.lang.reflect.Method.invokeNative(Native Method)
07-11 19:38:41.585: E/AndroidRuntime(729):  at java.lang.reflect.Method.invoke(Method.java:511)
07-11 19:38:41.585: E/AndroidRuntime(729):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-11 19:38:41.585: E/AndroidRuntime(729):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-11 19:38:41.585: E/AndroidRuntime(729):  at dalvik.system.NativeStart.main(Native Method)
07-11 19:38:41.585: E/AndroidRuntime(729): Caused by: java.lang.reflect.InvocationTargetException
07-11 19:38:41.585: E/AndroidRuntime(729):  at java.lang.reflect.Method.invokeNative(Native Method)
07-11 19:38:41.585: E/AndroidRuntime(729):  at java.lang.reflect.Method.invoke(Method.java:511)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.view.View$1.onClick(View.java:3586)
07-11 19:38:41.585: E/AndroidRuntime(729):  ... 11 more
07-11 19:38:41.585: E/AndroidRuntime(729): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.point/com.point.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Activity.startActivityForResult(Activity.java:3351)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Activity.startActivityForResult(Activity.java:3312)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Activity.startActivity(Activity.java:3522)
07-11 19:38:41.585: E/AndroidRuntime(729):  at android.app.Activity.startActivity(Activity.java:3490)
07-11 19:38:41.585: E/AndroidRuntime(729):  at com.point.MainActivity.sendMessage(MainActivity.java:34)
07-11 19:38:41.585: E/AndroidRuntime(729):  ... 14 more
07-11 19:43:41.995: I/Process(729): Sending signal. PID: 729 SIG: 9

SO 上的链接还说了一些关于不创建 TextView 并且它为 NULL 的内容。

有人能帮我吗?

4

3 回答 3

7

如果您更好地查看错误日志,您会看到:

引起:android.content.ActivityNotFoundException:找不到明确的活动类{com.point/com.point.DisplayMessageActivity};您是否在 AndroidManifest.xml 中声明了此活动?

那么,您在文件DisplayMessageActivity中声明了吗?AndroidManifest.xml

于 2012-07-11T20:45:07.317 回答
4

将此添加到应用程序标记下的清单文件中:

<activity android:name=".DisplayMessageActivity"></activity>
于 2012-07-11T20:46:55.287 回答
1

从您的堆栈跟踪:

Unable to find explicit activity class {com.point/com.point.DisplayMessageActivity}; 
have you declared this activity in your AndroidManifest.xml?

你?

于 2012-07-11T20:44:24.117 回答