繁体   English   中英

Android库中的ExceptionInInitializerError

[英]ExceptionInInitializerError in Android Library

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

也很少抛出该异常,在使用同一网络库的大约10,000个用途中,有7个用户发生了21次,并且在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();

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

我想我找到了答案,我也收到一条带有消息的RuntimeException

Can't create handler inside thread that has not called Looper.prepare()

该库正在创建一个AsyncTask,需要在UI线程上创建它。

如AsyncTask.java所说,这些崩溃中有100%(到目前为止有70例)发生在豆形软糖之前。

The AsyncTask class must be loaded on the UI thread. This is done automatically as of Build.VERSION_CODES.JELLY_BEAN.

希望这会对其他人有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM