gpt4 book ai didi

java - OkHttpClient 在将 Retrofit 更新为 Retrofit 2 后损坏

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:34:03 27 4
gpt4 key购买 nike

我从 retrofit 更新到 retrofit2 后出现此错误。

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 之间的几个不同版本,但都没有用。

有什么想法吗?提前致谢。

最佳答案

和你有同样的问题。

首先抛出:

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

Retrofit 具有 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'

希望能解决问题。

关于java - OkHttpClient 在将 Retrofit 更新为 Retrofit 2 后损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38604235/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com