Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple dex files define Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;

Tags:

java

android

dex

I am getting this error while I am trying to compile my project on android studio

app:transformClassesWithDexForDebug FAILED
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

    `com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-i386/bin/java'' finished with non-zero exit value 2`

Below is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "paritosh.d9.groceries"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.facebook.android:facebook-android-sdk:4.11.0'
    compile 'com.facebook.android:audience-network-sdk:4.7.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
}

Its been hours I am trying to solve this problem. I have tried to remove my play services dependencies but this didn't solve the issue. Please help me in solving this problem. Thanks

like image 551
Paritosh Chaudhary Avatar asked Mar 22 '26 11:03

Paritosh Chaudhary


1 Answers

You have duplication in dependencies – two classes are the same. You should understand which lib contains that one you should exclude. In order to do this, you need to run the next line in console:

./gradlew app:androidDependencies

Also, you can do the same with Gradle plugin in Android Studio:

enter image description here

The output will be like this:

+--- com.android.support:multidex:1.0.1
+--- io.realm:realm-android-library:1.0.0
|    \--- com.getkeepsafe.relinker:relinker:1.2.1
+--- com.android.support:appcompat-v7:23.3.0
|    +--- com.android.support:animated-vector-drawable:23.3.0
|    |    \--- com.android.support:support-vector-drawable:23.3.0
|    \--- com.android.support:support-vector-drawable:23.3.0
+--- com.android.support:design:23.3.0
|    +--- com.android.support:appcompat-v7:23.3.0
|    |    +--- com.android.support:animated-vector-drawable:23.3.0
|    |    |    \--- com.android.support:support-vector-drawable:23.3.0
|    |    \--- com.android.support:support-vector-drawable:23.3.0
|    \--- com.android.support:recyclerview-v7:23.3.0

Look for the duplication of gms lib and exclude it like this:

 compile(group: 'com.google.android.gms', name: 'play-services-gcm', version: "8.4.0") {
        exclude(group: 'com.google.android.gms', module: 'play-services-base')
        exclude(group: 'com.google.android.gms', module: 'play-services-basement')
    }

If you still can't solve the problem, please, show me the output of

./gradlew app:androidDependencies
like image 143
Val Avatar answered Mar 24 '26 05:03

Val



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!