Android google play services duplicate entry

2019-01-29 02:58发布

问题:

I'm trying to use google services in my Android app, but I was getting the following error:

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_11\bin\java.exe'' finished with non-zero exit value 2

I was told to try adding multiDexEnabled = true and now the error has changed to this:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/GooglePlayServicesAvailabilityException.class

I looked through my libs but wasn't able to find any conflicts between them.

My jars:
gdata-client-1.0.jar
gdata-client-meta-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-play-services.jar

My project gradle file has the following dependencies:

classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'

My module gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.mydomain.myproject"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile group: 'com.google.guava', name: 'guava', version: '18.0'
}

Any help on fixing these errors would be appreciated.

回答1:

I looked through my libs but wasn't able to find any conflicts between them

google-play-services.jar would appear to conflict with compile 'com.google.android.gms:play-services:7.5.0'. Remove that JAR and see if that helps.