該應用程序崩潰,但ACRA不出現。繼承人日誌:ACRA不起作用
11-20 16:50:19.119: ERROR/ACRA(23345): ACRA caught a RuntimeException exception for com.buggyproject. Building report.
11-20 16:50:19.539: ERROR/ACRA(23345): ACRA caught a RuntimeException exception for com.buggyproject. Building report.
11-20 16:50:19.909: ERROR/ACRA(23345): com.buggyproject fatal error : An error occured while executing doInBackground()
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at libcore.net.UriCodec.encode(UriCodec.java:132)
at java.net.URLEncoder.encode(URLEncoder.java:57)
at com.buggyproject.Api$UpdateUI.doInBackground(Api.java:309)
at com.buggyproject.Api$UpdateUI.doInBackground(Api.java:296)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
爲什麼它不起作用?它不能處理NullPointerException?
更新 下面的代碼片段用的AsyncTask類的doInBackground函數,其中NullPointExcetion是提高
@Override
protected String doInBackground(String... params) {
try{
String path = String.format("update/%s/%s/",
URLEncoder.encode(params[0], "UTF-8"),
URLEncoder.encode(params[1], "UTF-8"));
page = api.getPage(server.getAddress(), path);
return page;
} catch (UnsupportedEncodingException e){
Log.d(TAG_NAME, "Error URL encoding " + e.toString());
}
return null;
}
我覺得proble是PARAMS [0]或PARAMS [1]或兩者都爲空,但爲什麼ACRA沒有出現?
UPDATE2
另一個錯誤我已經注意到
channel '41f00be8 com.buggyproject/org.acra.CrashReportDialog (server)' ~ Channel is unrecoverably broken and will be disposed!
後com.buggyproject.Api類。 – user987339
@ user987339我已更新我的問題 – KennyPowers
在使用兩個URLEncoder.encode之前,請檢查params [0]和params [1]是否不爲空。 – gahfy