app:preDebugAndroidTestBuild

Android Gradle 报错:

Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’.
Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.0.0-beta1) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

解决方法 1

1st

appbuild.gradle 中, 在 android{…} 里添加如下代码:

configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
        }

2nd

同步 build.gradle 文件


解决方法 2

appbuild.gradle 中, 在 android{…} 里,更改一下属性,使其为最近版本号,如下

自行去官网里寻找适合版本 ——[developer.android.com]

andorid{
    ...
    defaultConfig {
     compileSdkVersion 27
        defaultConfig {
            ...
            targetSdkVersion 27
            ...
        }
        ...
    }
    ...
}

总结

新手注意看报错信息
‘.Conflict with dependency ‘com.android.support:support-annotations’
说明是依赖冲突,
Resolved versions for app (26.0.0-beta1) and test app (27.1.1) differ
给出了冲突的版本,之后要么把冲突的地方降级为 (26.0.0-beta1),
要么把整个升级为版本 27

感谢分享

你可能感兴趣的:(Android,Error,集锦,Android,Studio)