Google Gradle 中的映射冲突依赖

Google Maps conflict dependency in Gradle

我已尝试将 Google 地图片段添加到我的 android 应用程序。我添加依赖项

compile 'com.google.android.gms:play-services-maps:8.1.0'

然而,当我尝试同步 gradle 构建文件时,出现错误

Warning:Conflict with dependency 'com.android.support:support-annotations'. 
Resolved versions for app (22.2.0) and test app (23.0.1) differ.

根据另一个堆栈溢出答案的建议,我们 运行 Gradle 依赖项报告,发现唯一包含模块 22.2.0 的包是 google play one本身。

我曾尝试排除该模块,但这无济于事。

有人解决过这个问题吗?任何帮助将不胜感激。

我附上 build.gradle 文件的相关部分

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//./compile 'com.android.support:appcompat-v7:19.1.0'
    androidTestCompile ('com.android.support.test:runner:0.4') {
        exclude module: 'support annotations'
    }
    // Set this dependency to use JUnit 4 rules
    androidTestCompile ('com.android.support.test:rules:0.4') {
        exclude module: 'support annotations'
    }
    // Set this dependency to build and run Espresso tests
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
        exclude module: 'support annotations'
    }
    // Set this dependency to build and run UI Automator tests
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:8.1.0'
}

咦!早上遇到这个问题,现在看到这个问题。

我通过添加以下附加依赖项解决了问题:

androidTestCompile 'com.android.support:support-annotations:22.+'

我不确定正确的解析版本,因此保留通配符“+”,如果您确定用正确的通配符替换通配符。

您不会因为一个小错字而将支持注释模块从您的测试库中排除。在排除语句中将 "support annotations" 更改为 "support-annotations"。

exclude module: 'support-annotations'