程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> android-Android程序崩潰,求大神幫忙看看這是什麼原因

android-Android程序崩潰,求大神幫忙看看這是什麼原因

編輯:編程綜合問答
Android程序崩潰,求大神幫忙看看這是什麼原因

如題,代碼中沒錯誤,但是每次運行到那個方法就自動退出了。這是Logcat中的error列表,誰知道是什麼原因?

04-22 15:29:54.788: E/dalvikvm(3610): threadid=11: created from interp,name=Thread-3687
04-22 15:29:54.798: E/dalvikvm(3610): threadid=11: calling run(),name=Thread-3687
04-22 15:29:54.828: E/lanageTag(3610): not use
04-22 15:30:05.589: E/dalvikvm(3610): threadid=11: exiting,name=Thread-3687
04-22 15:30:30.546: E/AndroidRuntime(3610): FATAL EXCEPTION: main
04-22 15:30:30.546: E/AndroidRuntime(3610): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3021, result=-1, data=Intent { (has extras) }} to activity {com.example.ocr_test_13/com.example.ocr_test_13.MainActivity}: java.lang.ArithmeticException: divide by zero
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3221)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread.access$1100(ActivityThread.java:140)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.os.Handler.dispatchMessage(Handler.java:99)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.os.Looper.loop(Looper.java:137)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread.main(ActivityThread.java:4914)
04-22 15:30:30.546: E/AndroidRuntime(3610): at java.lang.reflect.Method.invokeNative(Native Method)
04-22 15:30:30.546: E/AndroidRuntime(3610): at java.lang.reflect.Method.invoke(Method.java:511)
04-22 15:30:30.546: E/AndroidRuntime(3610): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808)
04-22 15:30:30.546: E/AndroidRuntime(3610): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575)
04-22 15:30:30.546: E/AndroidRuntime(3610): at dalvik.system.NativeStart.main(Native Method)
04-22 15:30:30.546: E/AndroidRuntime(3610): Caused by: java.lang.ArithmeticException: divide by zero
04-22 15:30:30.546: E/AndroidRuntime(3610): at com.example.ocr_test_13.MainActivity.FindConnectArea(MainActivity.java:1158)
04-22 15:30:30.546: E/AndroidRuntime(3610): at com.example.ocr_test_13.MainActivity.Identify(MainActivity.java:735)
04-22 15:30:30.546: E/AndroidRuntime(3610): at com.example.ocr_test_13.MainActivity.onActivityResult(MainActivity.java:514)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.Activity.dispatchActivityResult(Activity.java:5276)
04-22 15:30:30.546: E/AndroidRuntime(3610): at android.app.ActivityThread.deliverResults(ActivityThread.java:3174)
04-22 15:30:30.546: E/AndroidRuntime(3610): ... 11 more
04-22 15:42:22.025: E/dalvikvm(7360): threadid=11: created from interp,name=Thread-3708
04-22 15:42:22.025: E/dalvikvm(7360): threadid=11: calling run(),name=Thread-3708
04-22 15:42:22.105: E/lanageTag(7360): not use


最佳回答:


04-22 15:30:30.546: E/AndroidRuntime(3610): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3021, result=-1, data=Intent { (has extras) }} to activity {com.example.ocr_test_13/com.example.ocr_test_13.MainActivity}: java.lang.ArithmeticException: divide by zero

是需要仔細的看出錯的 LOG,我剛開始學 Android 編程時,也不太會看這些 LOG。
其實,關鍵的就是一兩句,如上:divide by zero 告訴你除數為零了
所以你想檢查一下你的代碼,重點看看除運行。然後呢,在進行除運算前對除數進行判斷,除數為零就不要進行除運行了。最後是自己輸出一行 LOG 提示一下。

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