Android应用程序不会在模拟器上运行(第1000页):(

时间:2011-11-08 09:51:07

标签: android tabs

我是Android编程的新手,我写了一个应用程序来添加两个整数。但是,在执行时我收到错误'应用程序(com.android.xxxx)意外停止。日志如下所示。请帮我调试并理解这个问题:

11-08 02:02:17.671: E/AndroidRuntime(328):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-08 02:02:17.671: E/AndroidRuntime(328):  at dalvik.system.NativeStart.main(Native Method)
11-08 02:02:17.671: E/AndroidRuntime(328): Caused by: java.lang.NullPointerException
11-08 02:02:17.671: E/AndroidRuntime(328):  at com.android.add.AdditionActivity.onCreate(AdditionActivity.java:17)
11-08 02:02:17.671: E/AndroidRuntime(328):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-08 02:02:17.671: E/AndroidRuntime(328):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-08 02:02:17.671: E/AndroidRuntime(328):  ... 11 more
11-08 02:35:42.461: D/AndroidRuntime(1153): Shutting down VM
11-08 02:35:42.461: W/dalvikvm(1153): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-08 02:35:42.501: E/AndroidRuntime(1153): FATAL EXCEPTION: main
11-08 02:35:42.501: E/AndroidRuntime(1153): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.add/com.android.add.AdditionActivity}: java.lang.NullPointerException
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.os.Looper.loop(Looper.java:123)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at java.lang.reflect.Method.invokeNative(Native Method)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at java.lang.reflect.Method.invoke(Method.java:521)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at dalvik.system.NativeStart.main(Native Method)
11-08 02:35:42.501: E/AndroidRuntime(1153): Caused by: java.lang.NullPointerException
11-08 02:35:42.501: E/AndroidRuntime(1153):     at com.android.add.AdditionActivity.onCreate(AdditionActivity.java:17)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-08 02:35:42.501: E/AndroidRuntime(1153):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-08 02:35:42.501: E/AndroidRuntime(1153):     ... 11 more

1 个答案:

答案 0 :(得分:1)

您在AdditionActivity.java的第17行有一个NullPointerException,这会阻止您的活动启动。