程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 報錯-用Eclipse開發android 應用時,在logcat裡出現了fatal exception :main ,怎麼解決?

報錯-用Eclipse開發android 應用時,在logcat裡出現了fatal exception :main ,怎麼解決?

編輯:編程綜合問答
用Eclipse開發android 應用時,在logcat裡出現了fatal exception :main ,怎麼解決?

logcat 如下:

07-29 13:44:35.140: E/AndroidRuntime(375): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zhinengdiancan/com.zhinengdiancan.MainActivity}: java.lang.NullPointerException
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:126)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:3997)
07-29 13:44:35.140: E/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 13:44:35.140: E/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:491)
07-29 13:44:35.140: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-29 13:44:35.140: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-29 13:44:35.140: E/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
07-29 13:44:35.140: E/AndroidRuntime(375): Caused by: java.lang.NullPointerException
07-29 13:44:35.140: E/AndroidRuntime(375): at com.zhinengdiancan.MainActivity.LoadUserdata(MainActivity.java:222)
07-29 13:44:35.140: E/AndroidRuntime(375): at com.zhinengdiancan.MainActivity.onCreate(MainActivity.java:67)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
07-29 13:44:35.140: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
07-29 13:44:35.140: E/AndroidRuntime(375): ... 11 more

最佳回答:


com.zhinengdiancan.MainActivity.LoadUserdata(MainActivity.java:222)

從錯誤來看是在MainActivity中的222行的LoadUserdata方法出現了空指針,你檢查下那邊的值

telen0928
Jave_
telen0928
Jave_
telen0928
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved