加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

与项目’:app’中的依赖’com.android.support:support-annotat

发布时间:2020-12-14 00:51:55 所属栏目:百科 来源:网络整理
导读:我是Android App Development的新手.当我尝试创建一个新项目时,Android Project …弹出以下消息.. 错误:任务’:app:preDebugAndroidTestBuild’的执行失败. Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’.
我是Android App Development的新手.当我尝试创建一个新项目时,Android Project …弹出以下消息..

错误:任务’:app:preDebugAndroidTestBuild’的执行失败.

Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See 07000 for details.
Information:Gradle tasks [:app:generateDebugSources,:app:generateDebugAndroidTestSources,:app:mockableAndroidJar]

这是我项目的截图
click here to see screenshot of the error i got

我也尝试将此代码添加到我的依赖项中..
androidTestCompile’c??om.android.support:support-annotations:23.3.0′
这没有成功.我也试过27.1.1和26.1.0 ..
这也没有成功.

根据您的截图,我发现了两个有效的解决方案

第一个解决方案:在此行添加gradle模块的依赖项

compile 'com.android.support:support-annotations:27.1.1'

并同步你的项目

注意:如果您使用Android studio 3更改编译实现

第二种解决方案:配置文档https://developer.android.com/studio/build/gradle-tips.html#configure-project-wide-properties中的项目范围属性

在project gradle中添加以下行:

// This block encapsulates custom properties and makes them available to all
// modules in the project.
ext {
    // The following are only a few examples of the types of properties you can define.
    compileSdkVersion = 26
    // You can also use this to specify versions for dependencies. Having consistent
    // versions between modules can avoid behavior conflicts.
    supportLibVersion = "27.1.1"
}

然后访问此部分,将compileSdkVersionline更改为

compileSdkVersion rootProject.ext.compileSdkVersion

并在依赖项部分更改导入的库如下所示:

compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

并同步你的项目

注意:如果您使用Android studio 3更改编译实现

对于编译和实现之间的区别,请看这个
What’s the difference between implementation and compile in gradle

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读