1

有人可以在这里解释如何准确定位 eclipse 中的错误吗?例如像这样..

07-07 00:46:34.968: E/AndroidRuntime(401): FATAL EXCEPTION: main
07-07 00:46:34.968: E/AndroidRuntime(401): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.localhost.one/com.localhost.one.Main}: java.lang.NullPointerException
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.os.Looper.loop(Looper.java:123)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-07 00:46:34.968: E/AndroidRuntime(401):  at java.lang.reflect.Method.invokeNative(Native Method)
07-07 00:46:34.968: E/AndroidRuntime(401):  at java.lang.reflect.Method.invoke(Method.java:521)
07-07 00:46:34.968: E/AndroidRuntime(401):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-07 00:46:34.968: E/AndroidRuntime(401):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-07 00:46:34.968: E/AndroidRuntime(401):  at dalvik.system.NativeStart.main(Native Method)
07-07 00:46:34.968: E/AndroidRuntime(401): Caused by: java.lang.NullPointerException
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONTokener.nextValue(JSONTokener.java:90)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONArray.<init>(JSONArray.java:87)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONArray.<init>(JSONArray.java:103)
07-07 00:46:34.968: E/AndroidRuntime(401):  at com.localhost.one.Main.onCreate(Main.java:80)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-07 00:46:34.968: E/AndroidRuntime(401):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-07 00:46:34.968: E/AndroidRuntime(401):  ... 11 more

Eclipse IDE 非常棒,因为它有很多插件,但缺少 VS 的很多东西。如果有人可以告诉我如何准确定位我的错误或我的空指针在哪里,从什么变量,从 Eclipse 中的什么方法?谢谢。在eclipse中查找错误非常耗时..

4

1 回答 1

3

在这里你可以找到你的包名和错误

Caused by: java.lang.NullPointerException <<<<Error
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONTokener.nextValue(JSONTokener.java:90)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONArray.<init>(JSONArray.java:87)
07-07 00:46:34.968: E/AndroidRuntime(401):  at org.json.JSONArray.<init>(JSONArray.java:103)
07-07 00:46:34.968: E/AndroidRuntime(401):  at com.localhost.one.Main.onCreate(Main.java:80)


Line no.80 and class name Main.java
于 2012-07-07T06:01:15.927 回答