简体   繁体   中英

Google Maps conflict dependency in Gradle

I have tried to add a Google Map fragment to my android app. I add the dependency

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

However when I try to sync the gradle build file I get the error

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

On the advice of another stack overflow answer we ran the Gradle dependencies report, and found that the only package that includes the module 22.2.0 is the google play one itself.

I have tried to exclude the module but this is to no avail.

Has anyone solved this problem? Any help would be much appreciated.

I attach the relevant part of the build.gradle file

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'
}

You are not excluding the support annotations module from your testing libraries because of a small typo. Change "support annotations" to "support-annotations" in your exclude statements.

exclude module: 'support-annotations'

Huh! Faced this issue in the morning and now seeing this question.

I resolved by adding the following additional dependency:

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

I was not sure of the correct resolving version thereby kept with wildcard '+', if you are sure replace the wildcard with the right one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM