1

When I Clean/Rebuild my project or even run app, It doesn't return any errors. But when I generate signed APK, It returns two errors.

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzox;

And this one

    Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzd.class

Below is the code from build.gradle file.

apply plugin: 'com.android.application'


android {
    compileSdkVersion 24
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.wildlife.dbd"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 10
        versionName "2.2.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

dependencies
{
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'

    // FB Ads
    compile 'com.facebook.android:audience-network-sdk:4.10.0'

    // Analytics
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
}
WideFide
  • 335
  • 1
  • 3
  • 18
  • try commenting `apply plugin: 'com.google.gms.google-services'`. You don't need that line, as told in [Setting Up Google Play Services](https://developers.google.com/android/guides/setup). Except if you use firebase. But I don't see any firebase usage from your `build.gradle` – ישו אוהב אותך Jul 16 '16 at 21:23
  • Is there anything in the libs folder that you are compiling that conflicts with the gradle dependencies? – OneCricketeer Jul 17 '16 at 00:09
  • @isnotmenow I commented out that line but It's being used by Google Analytics. https://developers.google.com/analytics/devguides/collection/android/v4/ Hence, got another error. – WideFide Jul 18 '16 at 09:12
  • @cricket_007 There's nothing in libs folder. – WideFide Jul 18 '16 at 09:12
  • My bad, I was wrong. Though not related to your question, you should add `apply plugin: 'com.google.gms.google-services'` at the bottom as told in the documentation. – ישו אוהב אותך Jul 18 '16 at 09:37
  • @isnotmenow It's in the bottom already. And I have sorted out the first error but the second one still persists. :app:transformClassesWithJarMergingForRelease FAILED Any help on this is appreciated :) – WideFide Jul 18 '16 at 10:07

1 Answers1

3

Facebook audience network will pull in play-services as well, so you'll have to exclude it:

I don't remember exactly what Facebook's dependencies are, so your 'analytics' line might not be complete enough for the audience network to run properly. You might want to add the entire play services like so: compile 'com.google.android.gms:play-services:9.2.1', and remove analytics.

Or if you can see exactly which dependencies Facebook requires, you can grab the correct ones here.

compile ('com.facebook.android:audience-network-sdk:4.10.0') {
    exclude group: 'com.google.android.gms'
}
Bill
  • 4,506
  • 2
  • 18
  • 29