Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Error converting bytecode to dex: Multiple dex files define

i got this issues can u help me:

Error:Error converting bytecode to dex:

Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/internal/zzf; ...

FAILURE: Build failed with an exception.

  • What went wrong: 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: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --output D:\Projectos\Chat_Final\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\classes_9fd79174a0a6dc23209652a8a58b3e02e9146491.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\bolts-applinks-1.4.0_7536087ced7b51cacc52bdfc4ca05ab61d61e0c3.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\jackson-databind-2.2.2_c79be971c56bd1cdc38488184cf71a5146b761ff.jar D:\Projectos\Chat_Final\app\build\intermediates\pre-dexed\debug\classes_3b9a81b892f55e63da37657bf33b2ce2fe9ca8b0.jar

my build.glade

    packagingOptions {
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}

}

/* packagingOptions { exclude 'META-INF/LICENSE' //include below line if you are using firebase //exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' }*/

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'
    })
    testCompile 'junit:junit:4.12'


    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    //compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'


    compile 'com.android.support:appcompat-v7:25.0.1'

    compile 'com.firebase:firebase-client-android:2.4.0'
    compile 'com.google.firebase:firebase-core:10.2.6'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.firebase:firebase-database:10.2.6'
    compile 'com.google.firebase:firebase-storage:10.2.6'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.firebaseui:firebase-ui-database:0.6.0'
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'


    compile 'com.firebaseui:firebase-ui-auth:0.6.0'
    //compile 'com.android.support:multidex:1.0.0'

    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'


    compile 'com.squareup.okhttp3:okhttp:3.6.0'

    //Notification

    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'




    compile 'com.google.android.gms:play-services-gcm:10.2.6'

    compile 'com.google.android.gms:play-services-location:10.2.6'



}

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

like image 443
Atayd Chylauly Avatar asked Feb 04 '23 07:02

Atayd Chylauly


1 Answers

If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your app-level build.gradle file, as shown here:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

Modify the app-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

Create an Application class like this:

public class MyApplication extends MultiDexApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

Add this application class in Manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your package name">
    <application
        android:name=".MyApplication" >
        ...
    </application>
</manifest>

You can also check this link:

https://developer.android.com/studio/build/multidex.html

like image 199
Avijit Karmakar Avatar answered Feb 07 '23 12:02

Avijit Karmakar