Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versi

新建一个项目,总是提示下列错误:

原因:由于依赖包冲突;

解决方式:

在build.gradle文件中(app)

dependencies {

    //添加如下代码即可
    androidTestCompile('com.android.support:support-annotations:26.+') {
        force = true
    }
}

欢迎关注个人公众号(生活与认知): 

图片地址:https://i-blog.csdnimg.cn/blog_migrate/a33e03b6d30e38f9e144769d09078c0e.jpeg

This error message indicates that there is a conflict between different variants of the `org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0` dependency that your project is trying to use. The consumer was configured to find a runtime of a component compatible with Java 11, packaged as a jar, and its dependencies declared externally, but it cannot choose between the available variants of the dependency. To resolve this issue, you can try the following steps: - Check if your project is explicitly declaring a version of the `org.jetbrains.kotlin:kotlin-gradle-plugin` dependency that conflicts with the version required by the consumer (in this case, Java 11). If so, try updating the project to use the correct version of the dependency. - If the above step does not work, you can try adding a resolution strategy to your build script to force Gradle to choose the correct variant of the dependency. For example, you can add the following code to your `build.gradle` file: ``` configurations.all { resolutionStrategy { eachDependency { DependencyResolveDetails details -> if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name == 'kotlin-gradle-plugin' && details.requested.version == '1.7.0') { details.useVersion('1.7.0') } } } } ``` This code tells Gradle to use version `1.7.0` of the `org.jetbrains.kotlin:kotlin-gradle-plugin` dependency whenever it is required, regardless of any conflicting versions that may be present. If neither of these steps work, you may need to investigate further to find the root cause of the conflict.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沉淀的沙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值