all com.android.support libraries must use the exact same version specification when adding google plya-services

亡梦爱人 提交于 2019-12-11 14:19:40

问题


When adding google play-services library so I can add in a map I got this error:

all com.android.support libraries must use the exact same version specification

My dependencies are as follows:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.android.gms:play-services:+'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
}

I tried to change the android support version as well as the android play services version, but the error remained.


回答1:


Use a constant version, remove the +:

implementation 'com.google.android.gms:play-services:15.0.1'

And also avoid adding the whole API, choose only the one that you need, you can find them here. For example, if you know you will only need Google Maps then just add this:

implementation 'com.google.android.gms:play-services-maps:15.0.1'

Instead of the whole thing like you did.

EDIT:

Add this to your project build gradle file (not the module one):

repositories {
    maven {
        url "https://maven.google.com"
    }
}


来源:https://stackoverflow.com/questions/50648927/all-com-android-support-libraries-must-use-the-exact-same-version-specification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!