我在eclipse中为Android创建了一个简单的应用程序,但是app根本不起作用,当我启动时它立即停止,即使在模拟器中也是如此,eclipse中没有任何错误显示。这是我的模拟器错误日志。你可以帮我解决一下吗?
04-15 15:22:17.005: D/AndroidRuntime(1834): Shutting down VM
04-15 15:22:17.005: W/dalvikvm(1834): threadid=1: thread exiting with uncaught exception (group=0xb2a98ba8)
04-15 15:22:17.095: E/AndroidRuntime(1834): FATAL EXCEPTION: main
04-15 15:22:17.095: E/AndroidRuntime(1834): Process: com.munkodevelopment.wtffaktat, PID: 1834
04-15 15:22:17.095: E/AndroidRuntime(1834): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.munkodevelopment.wtffaktat/com.munkodevelopment.wtffaktat.MainActivity}: java.lang.NullPointerException
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.os.Handler.dispatchMessage(Handler.java:102)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.os.Looper.loop(Looper.java:136)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread.main(ActivityThread.java:5017)
04-15 15:22:17.095: E/AndroidRuntime(1834): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 15:22:17.095: E/AndroidRuntime(1834): at java.lang.reflect.Method.invoke(Method.java:515)
04-15 15:22:17.095: E/AndroidRuntime(1834): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-15 15:22:17.095: E/AndroidRuntime(1834): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-15 15:22:17.095: E/AndroidRuntime(1834): at dalvik.system.NativeStart.main(Native Method)
04-15 15:22:17.095: E/AndroidRuntime(1834): Caused by: java.lang.NullPointerException
04-15 15:22:17.095: E/AndroidRuntime(1834): at com.munkodevelopment.wtffaktat.MainActivity.onCreate(MainActivity.java:25)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.Activity.performCreate(Activity.java:5231)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-15 15:22:17.095: E/AndroidRuntime(1834): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
04-15 15:22:17.095: E/AndroidRuntime(1834): ... 11 more
04-15 15:22:43.735: I/Process(1834): Sending signal. PID: 1834 SIG: 9
答案 0 :(得分:0)
当您的启动器活动打开然后调用onCreate()方法时,并且在活动初始化时,存在任何nullpointer异常。这就是为什么活动在开幕前崩溃的原因。请查看:
的onCreate(MainActivity.java:25)
在MainActivity.java中第25行的onCreate()方法