2016-07-27 46 views
4

從改造更新到改造2後,我得到了此錯誤。OkHttpClient在更新改造之後破裂改造2

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)

我在應用程序中使用的庫版本是:

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並沒有一個工作。

任何想法?提前致謝。

回答

10

與您有同樣的問題。

首先拋出:

compile 'com.squareup.okhttp3:okhttp:3.2.0' 

改造具有okhttp3,因爲它是如此它不需要依賴。此外,當您檢查hereRetrofit 2.1.0取決於okhttp 3.3.0,所以可能會有衝突。請記住,最終的依賴版本是您在gradle文件中編寫的版本。如果你不寫,那麼Gradle會自動解決它並提取正確的版本。

也有日誌記錄攔截器和URLConnection的較新版本:

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' 
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1' 

希望能解決這個問題。