0

我创建了一个基于 android 教程的应用程序:http: //developer.android.com/training/basics/firstapp/index.html

除了应用程序名称外,代码完全相同,但应用程序是强制关闭的。

06-24 16:19:22.279: E/Zygote(33): setreuid() failed. errno: 2 06-24 16:19:33.028: E/Zygote(33): setreuid() failed. errno: 17 06-24 16:19:34.568: E/BatteryService(62): usbOnlinePath not found 06-24 16:19:34.568: E/BatteryService(62): batteryVoltagePath not found 06-24 16:19:34.568: E/BatteryService(62): batteryTemperaturePath not found 06-24 16:19:34.588: E/SurfaceFlinger(62): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 06-24 16:19:34.698: E/SensorService(62): couldn't open device for module sensors (Invalid argument) 06-24 16:19:39.449: E/System(62): Failure starting core service 06-24 16:19:39.449: E/System(62): java.lang.SecurityException 06-24 16:19:39.449: E/System(62): at android.os.BinderProxy.transact(Native Method) 06-24 16:19:39.449: E/System(62): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 06-24 16:19:39.449: E/System(62): at android.os.ServiceManager.addService(ServiceManager.java:72) 06-24 16:19:39.449: E/System(62): at com.android.server.ServerThread.run(SystemServer.java:206) 06-24 16:19:39.479: E/EventHub(62): could not get driver version for /dev/input/mouse0, Not a typewriter 06-24 16:19:39.479: E/EventHub(62): could not get driver version for /dev/input/mice, Not a typewriter 06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/Effect_Tick.ogg 06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressStandard.ogg 06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressSpacebar.ogg 06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressDelete.ogg 06-24 16:19:39.808: E/SoundPool(62): error loading /system/media/audio/ui/KeypressReturn.ogg 06-24 16:19:39.828: E/UsbObserver(62): java.lang.NullPointerException 06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.UsbObserver.init(UsbObserver.java:131) 06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.UsbObserver.<init>(UsbObserver.java:65) 06-24 16:19:39.828: E/UsbObserver(62): at com.android.server.ServerThread.run(SystemServer.java:402) 06-24 16:19:40.429: E/ThrottleService(62): Could not open GPS configuration file /etc/gps.conf 06-24 16:19:40.958: E/logwrapper(137): executing /system/bin/tc failed: No such file or directory 06-24 16:19:41.069: E/logwrapper(139): executing /system/bin/tc failed: No such file or directory 06-24 16:19:41.129: E/logwrapper(144): executing /system/bin/tc failed: No such file or directory 06-24 16:37:58.420: E/AndroidRuntime(345): FATAL EXCEPTION: main 06-24 16:37:58.420: E/AndroidRuntime(345): java.lang.IllegalStateException: Could not execute method of the activity 06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$1.onClick(View.java:2144) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View.performClick(View.java:2485) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$PerformClick.run(View.java:9080) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Handler.handleCallback(Handler.java:587) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.os.Looper.loop(Looper.java:123) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:37:58.420: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 16:37:58.420: E/AndroidRuntime(345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 16:37:58.420: E/AndroidRuntime(345): at dalvik.system.NativeStart.main(Native Method) 06-24 16:37:58.420: E/AndroidRuntime(345): Caused by: java.lang.reflect.InvocationTargetException 06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:37:58.420: E/AndroidRuntime(345): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.view.View$1.onClick(View.java:2139) 06-24 16:37:58.420: E/AndroidRuntime(345): ... 11 more 06-24 16:37:58.420: E/AndroidRuntime(345): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 16:37:58.420: E/AndroidRuntime(345): at android.app.Activity.startActivity(Activity.java:2933) 06-24 16:37:58.420: E/AndroidRuntime(345): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 16:37:58.420: E/AndroidRuntime(345): ... 14 more 06-24 16:38:47.529: E/AndroidRuntime(357): FATAL EXCEPTION: main 06-24 16:38:47.529: E/AndroidRuntime(357): java.lang.IllegalStateException: Could not execute method of the activity 06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$1.onClick(View.java:2144) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View.performClick(View.java:2485) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$PerformClick.run(View.java:9080) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Handler.handleCallback(Handler.java:587) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.os.Looper.loop(Looper.java:123) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:38:47.529: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 16:38:47.529: E/AndroidRuntime(357): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 16:38:47.529: E/AndroidRuntime(357): at dalvik.system.NativeStart.main(Native Method) 06-24 16:38:47.529: E/AndroidRuntime(357): Caused by: java.lang.reflect.InvocationTargetException 06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:38:47.529: E/AndroidRuntime(357): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.view.View$1.onClick(View.java:2139) 06-24 16:38:47.529: E/AndroidRuntime(357): ... 11 more 06-24 16:38:47.529: E/AndroidRuntime(357): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 16:38:47.529: E/AndroidRuntime(357): at android.app.Activity.startActivity(Activity.java:2933) 06-24 16:38:47.529: E/AndroidRuntime(357): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 16:38:47.529: E/AndroidRuntime(357): ... 14 more 06-24 16:43:20.070: E/AndroidRuntime(385): FATAL EXCEPTION: main 06-24 16:43:20.070: E/AndroidRuntime(385): java.lang.IllegalStateException: Could not execute method of the activity 06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$1.onClick(View.java:2144) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View.performClick(View.java:2485) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$PerformClick.run(View.java:9080) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Handler.handleCallback(Handler.java:587) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.os.Looper.loop(Looper.java:123) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:43:20.070: E/AndroidRuntime(385): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 16:43:20.070: E/AndroidRuntime(385): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 16:43:20.070: E/AndroidRuntime(385): at dalvik.system.NativeStart.main(Native Method) 06-24 16:43:20.070: E/AndroidRuntime(385): Caused by: java.lang.reflect.InvocationTargetException 06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:43:20.070: E/AndroidRuntime(385): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.view.View$1.onClick(View.java:2139) 06-24 16:43:20.070: E/AndroidRuntime(385): ... 11 more 06-24 16:43:20.070: E/AndroidRuntime(385): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 16:43:20.070: E/AndroidRuntime(385): at android.app.Activity.startActivity(Activity.java:2933) 06-24 16:43:20.070: E/AndroidRuntime(385): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 16:43:20.070: E/AndroidRuntime(385): ... 14 more 06-24 16:45:09.099: E/AndroidRuntime(425): FATAL EXCEPTION: main 06-24 16:45:09.099: E/AndroidRuntime(425): java.lang.IllegalStateException: Could not execute method of the activity 06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$1.onClick(View.java:2144) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View.performClick(View.java:2485) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$PerformClick.run(View.java:9080) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Handler.handleCallback(Handler.java:587) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.os.Looper.loop(Looper.java:123) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:45:09.099: E/AndroidRuntime(425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 16:45:09.099: E/AndroidRuntime(425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 16:45:09.099: E/AndroidRuntime(425): at dalvik.system.NativeStart.main(Native Method) 06-24 16:45:09.099: E/AndroidRuntime(425): Caused by: java.lang.reflect.InvocationTargetException 06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 16:45:09.099: E/AndroidRuntime(425): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.view.View$1.onClick(View.java:2139) 06-24 16:45:09.099: E/AndroidRuntime(425): ... 11 more 06-24 16:45:09.099: E/AndroidRuntime(425): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 16:45:09.099: E/AndroidRuntime(425): at android.app.Activity.startActivity(Activity.java:2933) 06-24 16:45:09.099: E/AndroidRuntime(425): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 16:45:09.099: E/AndroidRuntime(425): ... 14 more 06-24 18:20:31.070: E/AndroidRuntime(464): FATAL EXCEPTION: main 06-24 18:20:31.070: E/AndroidRuntime(464): java.lang.IllegalStateException: Could not execute method of the activity 06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$1.onClick(View.java:2144) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View.performClick(View.java:2485) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$PerformClick.run(View.java:9080) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Handler.handleCallback(Handler.java:587) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.os.Looper.loop(Looper.java:123) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 18:20:31.070: E/AndroidRuntime(464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 18:20:31.070: E/AndroidRuntime(464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 18:20:31.070: E/AndroidRuntime(464): at dalvik.system.NativeStart.main(Native Method) 06-24 18:20:31.070: E/AndroidRuntime(464): Caused by: java.lang.reflect.InvocationTargetException 06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 18:20:31.070: E/AndroidRuntime(464): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.view.View$1.onClick(View.java:2139) 06-24 18:20:31.070: E/AndroidRuntime(464): ... 11 more 06-24 18:20:31.070: E/AndroidRuntime(464): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 18:20:31.070: E/AndroidRuntime(464): at android.app.Activity.startActivity(Activity.java:2933) 06-24 18:20:31.070: E/AndroidRuntime(464): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 18:20:31.070: E/AndroidRuntime(464): ... 14 more 06-24 18:25:12.590: E/AndroidRuntime(477): FATAL EXCEPTION: main 06-24 18:25:12.590: E/AndroidRuntime(477): java.lang.IllegalStateException: Could not execute method of the activity 06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$1.onClick(View.java:2144) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View.performClick(View.java:2485) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$PerformClick.run(View.java:9080) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Handler.handleCallback(Handler.java:587) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Handler.dispatchMessage(Handler.java:92) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.os.Looper.loop(Looper.java:123) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 18:25:12.590: E/AndroidRuntime(477): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-24 18:25:12.590: E/AndroidRuntime(477): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-24 18:25:12.590: E/AndroidRuntime(477): at dalvik.system.NativeStart.main(Native Method) 06-24 18:25:12.590: E/AndroidRuntime(477): Caused by: java.lang.reflect.InvocationTargetException 06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invokeNative(Native Method) 06-24 18:25:12.590: E/AndroidRuntime(477): at java.lang.reflect.Method.invoke(Method.java:507) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.view.View$1.onClick(View.java:2139) 06-24 18:25:12.590: E/AndroidRuntime(477): ... 11 more 06-24 18:25:12.590: E/AndroidRuntime(477): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml? 06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-24 18:25:12.590: E/AndroidRuntime(477): at android.app.Activity.startActivity(Activity.java:2933) 06-24 18:25:12.590: E/AndroidRuntime(477): at com.myfirstapp.MyFirstActivity.sendMessage(MyFirstActivity.java:26) 06-24 18:25:12.590: E/AndroidRuntime(477): ... 14 more <code>

不知道如何调试这个应用程序。请指教

谢谢

萨米尔

4

5 回答 5

1
  • 找不到显式活动类 {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity};您是否在 AndroidManifest.xml 中声明了此活动?

将 DisplayMessageActivity 的条目放在清单中......

它 DisplayMessageActivity 是第一个 Activity 使用意图过滤器,其他删除它。

<activity android:name=".DisplayMessageActivity" android:label="Demo App">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
于 2012-06-26T17:53:08.333 回答
1

答案在 logcat 中:

Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myfirstapp/DisplayMessageActivity.java.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?

像这样在清单中声明活动(即在<application>and</application>标记之间的某处插入它):

<activity android:name=".DisplayMessageActivity" />

这是一个常见的初学者错误......在你习惯它之前,至少要多看几次这个错误。:)

于 2012-06-26T17:53:31.780 回答
1

将其添加到 DisplayMessageActivity 清单中

<application ... >
    <activity android:name=".DisplayMessageActivity" />
    ...
</application>
于 2012-06-26T17:55:23.967 回答
0

确保将项目中的其他活动添加到 AndroidManifest.xml

于 2012-06-26T17:54:08.910 回答
0

您必须在清单中包含您的活动,例如:

<activity android:name=".MyFirstActivity"
            android:theme="@android:style/Theme.NoTitleBar">

        </activity>
于 2012-06-26T17:54:50.177 回答