【问题标题】:E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Version inconsistency 4.9.0 and 4.11.0 How to resolve?E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Version inconsistency 4.9.0 and 4.11.0 如何解决?
【发布时间】:2021-01-31 14:43:29
【问题描述】:

这是我的 okhttp gradle 版本:

implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'

还有我的 okHttp 记录器库。

implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'

我在 github 上发现了这个问题,并在此处回复说这是由于版本不一致造成的。 https://github.com/square/okhttp/issues/2839#issuecomment-244923226

但是 Okhttp 记录器还没有更新他们的库 OkHttp 版本,它是 4.9.0 但 okHttp 是 4.11.0 。我可以将版本降低到4.9.0,但我不想这样做。就像杰克沃顿在这里的推荐:https://github.com/square/okhttp/issues/2839#issuecomment-245269471

E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: tech.guzo.awtar, PID: 7624
    java.lang.NoSuchMethodError: No virtual method log(ILjava/lang/String;Ljava/lang/Throwable;)V in class Lokhttp3/internal/platform/Platform; or its super classes (declaration of 'okhttp3.internal.platform.Platform' appears in /data/app/tech.guzo.awtar-XZo1TJ-jaQnVlyXeTlwUdQ==/base.apk!classes3.dex)
        at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:111)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:159)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at com.yenepay.yegid.net.ServerAPI$1.intercept(ServerAPI.java:106)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
    

有人可以告诉我你是如何克服这个问题的吗?

【问题讨论】:

    标签: android logging retrofit2 okhttp android-glide


    【解决方案1】:

    你不应该依赖临时依赖,你应该只列出你在运行时依赖的所有版本作为你的直接依赖。

    implementation 'com.squareup.okhttp3:okhttp:4.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    

    【讨论】:

    • 所以降级我的版本是唯一的手段吗?保持所有版本相同对吗?我已经检查过了,这很好用..所以我想我应该保持这种方式..谢谢@yuri-schimke
    • 现在应该将所有内容升级到 4.9.0。 4.11.0 是 glide 是另一个项目。
    猜你喜欢
    • 2019-05-19
    • 1970-01-01
    • 2016-07-14
    • 2017-02-18
    • 1970-01-01
    • 2020-03-03
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    相关资源
    最近更新 更多