大家好,我是编程新手,需要一些帮助,我希望你们中有一个可以帮助我的人:
当我运行AVD模拟器时,然后单击我的按钮,我收到错误消息“不幸的是,事件记录已停止”。
这就是我的LogCat所说的:
04-11 22:08:10.415: D/dalvikvm(544): Not late-enabling CheckJNI (already on)
04-11 22:08:10.955: D/(544): Created
04-11 22:08:11.445: D/gralloc_goldfish(544): Emulator without GPU emulation detected.
04-11 22:08:19.615: D/AndroidRuntime(544): Shutting down VM
04-11 22:08:19.615: W/dalvikvm(544): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
04-11 22:08:19.655: E/AndroidRuntime(544): FATAL EXCEPTION: main
04-11 22:08:19.655: E/AndroidRuntime(544): java.lang.IllegalStateException: Could not execute method of the activity
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$1.onClick(View.java:3039)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View.performClick(View.java:3480)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$PerformClick.run(View.java:13983)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Handler.handleCallback(Handler.java:605)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Looper.loop(Looper.java:137)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.ActivityThread.main(ActivityThread.java:4340)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-11 22:08:19.655: E/AndroidRuntime(544): at dalvik.system.NativeStart.main(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): Caused by: java.lang.reflect.InvocationTargetException
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$1.onClick(View.java:3034)
04-11 22:08:19.655: E/AndroidRuntime(544): ... 11 more
04-11 22:08:19.655: E/AndroidRuntime(544): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.eventrecorder/com.example.eventrecorder.NewEvent}; have you declared this activity in your AndroidManifest.xml?
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Activity.startActivityForResult(Activity.java:3190)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Activity.startActivity(Activity.java:3297)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.example.eventrecorder.MainActivity.showAddForm(MainActivity.java:45)
04-11 22:08:19.655: E/AndroidRuntime(544): ... 14 more
答案 0 :(得分:1)
您的AndroidManifest.xml
文件没有<activity>
元素且android:name
属性为com.example.eventrecorder.NewEvent
。
如果NewEvent
应该是一项活动,则需要添加关联的<activity>
元素。
如果NewEvent
不是活动,请转到MainActivity
方法的第{45}行,并修复您使用的showAddForm()
Intent
是一个指向实际活动的人。