Error generating APK: "All com.google.android.gms libraries must use the exact same version specification"

1

When I try to generate the APK in Android studio I get this error message:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: 
duplicate entry: com/google/firebase/appindexing/Action$Builder$StatusType.class

I am using google maps, apparently it is a duplicity error but I would not know how to map it.

I do not know if it will have something to do but in my gradle file I get an error:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    multiDexEnabled  true
    applicationId "com.example.bryan.pruebawebservice"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:multidex:1.0.1'
//ACA ESTA EL ERROR ---->>>
compile 'com.google.android.gms:play-services-appindexing:9.8.0'

compile 'com.google.code.gson:gson:2.4'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
}

The error is:

  

All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 9.8.0, 10.0.1. Examples include com.google.android.gms: play-services-appindexing: 9.8.0 and com.google.android.gms: play-services-base: 10.0.1

    
asked by Bryan Luna 20.02.2017 в 16:17
source

2 answers

2

The error message indicates the problem:

  

All com.google.android.gms libraries must use the exact same version   specification (mixing versions can lead to runtime crashes). Found   versions 9.8.0, 10.0.1. Examples include   com.google.android.gms: play-services-appindexing: 9.8.0 and   com.google.android.gms: play-services-base: 10.0.1

Use the same version of com.google.android.gms:play-services in this case on 10.0.1 according to your build.gradle :

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'

It may be necessary to install the repository of this version, when you finish simply synchronize the build.gradle with your project.

    
answered by 20.02.2017 в 18:06
0

The error is clear:

  

All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 9.8.0, 10.0.1. Examples include com.google.android.gms: play-services-appindexing: 9.8.0 and com.google.android.gms: play-services-base: 10.0.1

Look at what you are compiling:

...
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
...

compile 'com.google.android.gms:play-services:10.0.1'
...

The compiler gets angry and says: when it comes to com.google.android.gms ... do not tell me to use two versions, or 9.8.0 or 10.0.1 :)

Then:

From the com.google.android.gms library that you have in the gradle that is showing up wrong:

Put the latest version. That is, change:

compile 'com.google.android.gms:play-services-appindexing:9.8.0'

for

compile 'com.google.android.gms:play-services-appindexing:10.0.1'

If you still give an error, leave only:

compile 'com.google.android.gms:play-services:10.0.1'
    
answered by 20.02.2017 в 17:53