FATAL EXCEPTION: OkHttp Dispatcher
Process: nz.co.datacom.mars.junction,PID: 21616
java.lang.NoSuchMethodError: No virtual method
log(Ljava/lang/String;)V in class Lokhttp3/internal/Platform; or its
super classes (declaration of ‘okhttp3.internal.Platform’ appears in
/data/app/nz.co.datacom.mars.junction-1/base.apk)
at
okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:109)
at
okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:157)
at
okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:190)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
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)
我在应用程序中使用的libs版本是:
compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0' compile 'com.squareup:otto:1.3.7' compile 'com.google.code.gson:gson:2.6.2' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
不确定是否是因为okhttp版本,但我尝试了2.3.0和3.4.0之间的几个不同的版本,但没有一个工作.
有任何想法吗?提前致谢.
解决方法
首先,扔出去:
compile 'com.squareup.okhttp3:okhttp:3.2.0'
改造有okhttp3因为它的依赖性所以它不需要.而且,当你检查here Retrofit 2.1.0取决于okhttp 3.3.0时,可能会有冲突.请记住,最终的依赖版本是您在gradle文件中编写的版本.如果您不编写它,Gradle会自动解析它并获取正确的版本.
还有一个更新版本的Logging Interceptor和urlconnection:
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
希望能解决问题.