好吧,我知道我有问题,我花了最后几个小时才发现问题,但我不能。从这个LogCat我怎样才能弄清楚究竟是什么问题?
03-17 22:42:39.710: E/AndroidRuntime(5168): FATAL EXCEPTION: main
03-17 22:42:39.710: E/AndroidRuntime(5168): java.lang.RuntimeException: Unable to start
ComponentInfo{com.example.transparentphone/com.example.transparentphone.MainActivity}:
java.lang.NullPointerException
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2065)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2090)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread.access$600(ActivityThread.java:136)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.os.Looper.loop(Looper.java:137)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread.main(ActivityThread.java:4802)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
java.lang.reflect.Method.invokeNative(Native Method)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
java.lang.reflect.Method.invoke(Method.java:511)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:580)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
dalvik.system.NativeStart.main(Native Method)
03-17 22:42:39.710: E/AndroidRuntime(5168): Caused by: java.lang.NullPointerException
03-17 22:42:39.710: E/AndroidRuntime(5168): at
com.example.transparentphone.MainActivity.onCreate(MainActivity.java:207)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.Activity.performCreate(Activity.java:5013)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-17 22:42:39.710: E/AndroidRuntime(5168): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2029)
03-17 22:42:39.710: E/AndroidRuntime(5168): ... 11 more
答案 0 :(得分:2)
首先查看(并发布)MainActivity.onCreate()
中MainActivity.java的第207行。如果源代码中不清楚,您可以在该行上设置断点,看看它是什么。
答案 1 :(得分:1)
您感兴趣的部分是:
03-17 22:42:39.710: E/AndroidRuntime(5168): Caused by: java.lang.NullPointerException
03-17 22:42:39.710: E/AndroidRuntime(5168): at com.example.transparentphone.MainActivity.onCreate(MainActivity.java:207)
所以崩溃发生在MainActivity.java
第207行。