0

我从 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被抛出,但我找不到类无法正确初始化的任何原因。

这个异常也很少被抛出,它发生了 21 次,有 7 个用户,在同一网络库的约 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();

如果您需要更多代码,请告诉我。

4

1 回答 1

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.

希望这对其他人有帮助!

于 2013-07-04T06:45:50.220 回答