android错误Could not resolve com.squareup.okhttp3:okhttp:{strictly 3.9.1}

本文介绍了解决Android项目中依赖版本冲突的方法。通过在Gradle配置文件中使用resolutionStrategy及force关键字来指定特定版本的依赖,确保项目稳定运行。

android错误Could not resolve com.squareup.okhttp3:okhttp:{strictly 3.9.1}

Cannot find a version of ‘’ that satisfies the version constraints
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这个问题是版本冲突问题,加入下面的代码,大概的意思就是 使用的这个第三方包版本各不一样,不能确定使用那个版本,需要在force中指定强制使用某各版本即可,指定方法如下,在gradle中指定:

configurations.all {
    resolutionStrategy {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.core') {
                details.useVersion "1.1.0"
            }
            if (details.requested.group == 'androidx.lifecycle') {
                details.useVersion "2.0.0"
            }
            if (details.requested.group == 'androidx.versionedparcelable') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.fragment') {
                details.useVersion "1.0.0"
            }
            if (details.requested.group == 'androidx.appcompat') {
                details.useVersion "1.0.1"
            }

        }
        force 'com.squareup.okhttp3:okhttp:3.9.1'
        force 'com.squareup.okio:okio:1.13.0'
    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值