且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-04-25 21:34:45

根据您的屏幕截图,我找到了两个可行的解决方案:

Based on your screenshot i found two working solutions:

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

First solution: add to dependencies of your gradle module this line

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

并同步您的项目

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

Note: if you are using Android studio 3+ change compile to implementation

第二个解决方案:配置文档在项目gradle中添加以下行:

in project gradle add this line:

// 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行更改为

Then to access this section change compileSdkVersionline to be

compileSdkVersion rootProject.ext.compileSdkVersion

并在dependencies部分将导入的库更改为如下所示:

and at dependencies section change the imported library to be like this:

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

并同步您的项目

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

Note: if you are using Android studio 3+ change compile to implementation

关于compileimplementation之间的区别,请看这里 实现和gradle编译之间有什么区别

For the difference between compile and implementation look at this What's the difference between implementation and compile in gradle