gpt4 book ai didi

android - 与项目 'com.android.support:support-annotations' 中的依赖项 ':app' 冲突。应用程序 (26.1.0) 和测试应用程序 (27.1.1) 的已解决版本不同。

转载 作者:IT老高 更新时间:2023-10-28 13:06:37 33 4
gpt4 key购买 nike

我是 Android 应用开发新手。当我尝试创建一个新项目时,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 https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details. Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]

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

我也尝试将此代码添加到我的依赖项中。androidTestCompile 'com.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+,请将 compile 更改为 implementation

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

在项目 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"
}

然后要访问此部分,请将 compileSdkVersion 行更改为

compileSdkVersion rootProject.ext.compileSdkVersion

并在 dependencies 部分将导入的库更改为:

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

并同步您的项目

注意:如果您使用的是 Android Studio 3+,请将 compile 更改为 implementation

compileimplementation 的区别看这里 What's the difference between implementation and compile in gradle

关于android - 与项目 'com.android.support:support-annotations' 中的依赖项 ':app' 冲突。应用程序 (26.1.0) 和测试应用程序 (27.1.1) 的已解决版本不同。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50117626/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com