2014-04-11 78 views
0

嗨,大家好,我完全新的節目,需要一些幫助,我希望你們中的一個可愛的人可以幫助我:在這條線找到多個註釋:

當我運行的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

這是一個非常令人困惑的問題,因爲您在標題中聲明的問題只能在您運行應用程序之前發生(並且您的應用程序無法運行,直到您修復它)。 logcat是來自運行時錯誤,我似乎很清楚 - 由於:android.content.ActivityNotFoundException:無法找到顯式活動類{com.example.eventrecorder/com.example.eventrecorder.NewEvent};你有沒有在你的AndroidManifest.xml?中聲明這個活動? – Simon

回答

1

AndroidManifest.xml文件不具有<activity>元素與com.example.eventrecorder.NewEvent一個android:name屬性。

如果NewEvent應該是一項活動,您需要添加關聯的<activity>元素。

如果NewEvent不應該是一個活動,去行MainActivity 45,在你showAddForm()方法,並修復您使用的startActivity()是一個指向一個實際的活動Intent