androidsegment-io

Com.google.android.gms has already been added to output. Please remove duplicate objects


I was trying to move my app's analytics from Mixpanel and Google Analytics to Segment.io. When I tried to build my app, it is always failed. Based on some googling, I thought there is a library duplicated. But I couldn't figure out which library causes this problem.

Is there anyway I can trace which library causes the problem?

Thank you.

app/libs


adapter-1.0.1.jar
android-async-http-1.4.3.jar
android-viewbadger.jar
commons-lang3-3.3.1.jar
endless-1.2.3.jar
GoogleConversionTrackingSdk-2.2.1.jar
libphonenumber-5.9.jar
Parse-1.8.2.jar
PayPal_MECL.jar
PayPalAndroidSDK-2.8.4.jar

build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"

    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services-base:6.5.87'
    compile 'com.google.android.gms:play-services-appindexing:6.5.87'
    compile 'com.google.android.gms:play-services-gcm:7.0.0'
    compile 'com.google.android.gms:play-services-location:7.0.0'
    compile 'com.google.android.gms:play-services-maps:6.5.87'
    compile 'com.google.android.gms:play-services-wallet:6.5.87'
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.parse.bolts:bolts-android:1.1.2'
    compile 'com.facebook.android:facebook-android-sdk:3.23.1'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'se.emilsjolander:stickylistheaders:2.6.0'
    compile 'com.sothree.slidinguppanel:library:3.0.0'
    compile 'com.squareup.picasso:picasso:2.5.0'

    apt 'com.michaelpardo:ollie-compiler:0.3.1'
    compile 'com.michaelpardo:ollie:0.3.1'

    compile project(':SlidingMenuLibrary')
    compile project(':ProgressWheel-master')
    compile project(':simplecropimagelib')
    compile 'com.splunk.mint:mint:4.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
        transitive = true;
    }
    compile('com.segment.analytics.android:analytics-core:+') {
        transitive = true
    }
    compile('com.segment.analytics.android:analytics-integration-google-analytics:3.1.5') {
        transitive = true
    }
    // Add other dependencies as you want here
    compile('com.segment.analytics.android:analytics-integration-mixpanel:+') {
        transitive = true
    }
    // Add other dependencies as you want here
    compile('com.segment.analytics.android:analytics-integration-localytics:+') {
        transitive = true
    }
}

Error:Class com.google.android.gms.internal.zzpw has already been added to output. Please remove duplicate copies.

Error:Class com.google.android.gms.internal.zzoy has already been added to output. Please remove duplicate copies. 2 errors; aborting

Error:Execution failed for task ':app:dexStagingDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/abrahamks/Development/android-sdk-macosx/build-tools/22.0.1/dx -JXmx2048M --dex --no-optimize --output /WOM-Android/app/build/intermediates/dex/staging/debug --input-list=/WOM-Android/app/build/intermediates/tmp/dex/staging/debug/inputList.txt

Error Code: 1

Output: UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzpw; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122) at com.android.dx.dex.file.DexFile.add(DexFile.java:161) at com.android.dx.command.dexer.Main.processClass(Main.java:732) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzoy; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122) at com.android.dx.dex.file.DexFile.add(DexFile.java:161) at com.android.dx.command.dexer.Main.processClass(Main.java:732) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) 2 errors; aborting


Solution

  • I thought you have inconsistent Google Play Service major version.

    Try to use same major version of the library. For example, upgrade your library to 7.5.0.

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
    
        apt "org.androidannotations:androidannotations:$AAVersion"
        compile "org.androidannotations:androidannotations-api:$AAVersion"
    
        compile 'com.google.code.gson:gson:2.3.1'
        compile 'com.google.android.gms:play-services-base:7.5.0'
        compile 'com.google.android.gms:play-services-appindexing:7.5.0'
        compile 'com.google.android.gms:play-services-gcm:7.5.0'
        compile 'com.google.android.gms:play-services-location:7.5.0'
        compile 'com.google.android.gms:play-services-maps:7.5.0'
        compile 'com.google.android.gms:play-services-wallet:7.5.0'
        compile 'com.android.support:support-v4:22.1.1'
        compile 'com.parse.bolts:bolts-android:1.1.2'
        compile 'com.facebook.android:facebook-android-sdk:3.23.1'
        compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
        compile 'se.emilsjolander:stickylistheaders:2.6.0'
        compile 'com.sothree.slidinguppanel:library:3.0.0'
        compile 'com.squareup.picasso:picasso:2.5.0'
    
        apt 'com.michaelpardo:ollie-compiler:0.3.1'
        compile 'com.michaelpardo:ollie:0.3.1'
    
        compile project(':SlidingMenuLibrary')
        compile project(':ProgressWheel-master')
        compile project(':simplecropimagelib')
        compile 'com.splunk.mint:mint:4.1'
        compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
            transitive = true;
        }
        compile('com.segment.analytics.android:analytics-core:+') {
            transitive = true
        }
        compile('com.segment.analytics.android:analytics-integration-google-analytics:3.1.5') {
            transitive = true
        }
        // Add other dependencies as you want here
        compile('com.segment.analytics.android:analytics-integration-mixpanel:+') {
            transitive = true
        }
        // Add other dependencies as you want here
        compile('com.segment.analytics.android:analytics-integration-localytics:+') {
            transitive = true
        }
    }