0

本项目本身已经包含了okhttp库,是3.3.1版本,使用完好
库如下

compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'

今天需要用到又拍云上传服务器,于是导入了又拍云的sdk,
compile 'com.upyun:upyun-android-sdk:2.0.5'

于是报错,

java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
 at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
                                                                            Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/http/HttpEngine;
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:232)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall.execute(RealCall.java:69)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171)
at rx.internal.operators.OperatorSubscribeOn$1$1$1.request(OperatorSubscribeOn.java:80)
at rx.Subscriber.setProducer(Subscriber.java:209)
at rx.internal.operators.OperatorSubscribeOn$1$1.setProducer(OperatorSubscribeOn.java:76)
at rx.Subscriber.setProducer(Subscriber.java:205)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:9861)
at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:221)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
                                                                         Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.http.HttpEngine" on path: DexPathList[[zip file "/data/app/com.app.allimu.ydactivity-2/base.apk"],nativeLibraryDirectories=[/data/app/com.app.allimu.ydactivity-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at 
okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:232) 
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) 
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) 
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185) 
at okhttp3.RealCall.execute(RealCall.java:69) 
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171) 
at rx.internal.operators.OperatorSubscribeOn$1$1$1.request(OperatorSubscribeOn.java:80) 
at rx.Subscriber.setProducer(Subscriber.java:209) 
at rx.internal.operators.OperatorSubscribeOn$1$1.setProducer(OperatorSubscribeOn.java:76) 
at rx.Subscriber.setProducer(Subscriber.java:205) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152) 
at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138) 
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) 
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) 
at rx.Observable.unsafeSubscribe(Observable.java:9861) 
at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) 
at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:221) 
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
                                                                               Suppressed: java.lang.ClassNotFoundException: okhttp3.internal.http.HttpEngine
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 26 more
                                                                            Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

上网查找说是版本号不一致所以报错,或者okhttp冲突,故把第一个库
compile 'com.squareup.okhttp3:okhttp:3.3.1'
给注释了,还是报错。两个都注释的话,有部分包导不进来,想问一下,有人遇到这个情况不,如何解决
还没有写代码,导入之后,之前的okhttp代码就不行了。

顺便问一下有没有断点上传清晰的demo,官方demo我觉得有点模糊了,注释不清楚,官方文档挺乱的
建议官方文档可以参照一下bomb云的官方文档,更简洁,更易懂。
谢谢。

1 个回答

0

已采纳

自己找到了答案,分享给大家,这个问题出现的原因主要是又拍云sdk里面okhttp与本身的okhttp版本不一样
首先
//compile 'com.squareup.okhttp3:okhttp:3.3.1'
先把第一个okhttp注释掉,因为sdk里面有一样的,保留会冲突,
然后
导入sdk然后通过project观看文件夹里面的jar包发现,sdk包含的okhttp是3.8.0版本
所以把
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
改成
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
然后就完美运行。
也有一部分人是因为rxjava冲突什么的,这里就不展开说了,因为该sdk里面没有包含rxjava
不过原理应该是一样,你导入的某个包与你本身的包有冲突或者版本不一致,
谢谢大家,忙了一天,搞定,收工。