NoSuchMethodError

今天在请求网络的时候遇到了如下问题

java.io.IOException: canceled due to 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/~~CTMez4oVeQIukZV-KAfXnQ==/com.autoai.media.center-3E_sT_w19P965eO8b8fphw==/base.apk!classes4.dex)

我的网络请求放到共通模块下了,但是奇怪的是我其他模块的网络请求是好用的 ,就说明共通模块没问题,后来调查发现是因为目前的模块引入了一个三方的sdk,我的okhttp的版本和他们冲突了,他们用的是com.squareup.okhttp3:okhttp:4.10.0我用的是com.squareup.okhttp3:okhttp:3.12.0,这就导致了编译时使用的库和运行时使用的库版本不匹配。然后我在当前的模块下加入下面的代码,问题解决!

    implementation com.squareup.okhttp3:okhttp:4.10.0
    implementation com.squareup.okhttp3:logging-interceptor:4.10.0
    configurations.configureEach {
        resolutionStrategy.force com.squareup.okhttp3:okhttp:4.10.0
        resolutionStrategy.force com.squareup.okhttp3:logging-interceptor:4.10.0
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值