我从Android网络库获得ExceptionInInitializerError
,然后是NoClassDefFoundError
。
https://github.com/bclymer/bc-rest-client/blob/master/src/com/bclymer/rest/BcRestClient.java
这是导致异常被抛出的文件,但正如您可以看到它找不到的类com/bclymer/rest/BcRestClient$DownloadWebSourceTask
,正好在方法performRequest
下方。从我读到的ExceptionInInitializerError
将导致NoClassDefFoundError
被抛出,但我找不到该类无法正确初始化的任何原因。
此异常也很少被抛出,对于7个用户来说发生了21次,在同一个网络库中使用了大约10,000次,而在MusicService中使用相同的方法进行了大约4,000次。
Fatal Exception java.lang.NoClassDefFoundError
com/bclymer/rest/BcRestClient$DownloadWebSourceTask
BcRestClient.java line 140
com.bclymer.rest.BcRestClient.performRequest
BcRestClient.java line 139
com.bclymer.rest.BcRestClient.access$3
BcRestClient.java line 415
com.bclymer.rest.BcRestClient$Builder.executeAsync
MusicService.java line 436
com.xxx.xxx.media.MusicService$5.run
ThreadPoolExecutor.java line 1076
java.util.concurrent.ThreadPoolExecutor.runWorker
Thread.java line 856
java.lang.Thread.run
我正在向图书馆发出请求:
new BcRestClient.Builder("http://www.validurl.com", RequestType.GET)
.setCastClass(SetResponse.class)
.setRestClientCallback(new BcRestClientCallback<SetResponse>() {
@Override
public void onPreExecute() {
}
@Override
public void onPostExecute() {
}
@Override
public void onSuccess(BcRestClientResponse<SetResponse> response) {
}
@Override
public void onFailure(BcRestClientResponse<SetResponse> response) {
}
}).executeAsync();
如果您需要更多代码,请与我们联系。
答案 0 :(得分:0)
我想我找到了答案,我也收到了RuntimeException
的消息
Can't create handler inside thread that has not called Looper.prepare()
库正在创建一个AsyncTask,需要在UI线程上创建。
这些崩溃中有100%(到目前为止70次)发生在预先的软糖之上,正如AsyncTask.java所说
The AsyncTask class must be loaded on the UI thread. This is done automatically as of Build.VERSION_CODES.JELLY_BEAN.
希望这会对其他人有所帮助!