问题
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