user3606902 user3606902 - 30 days ago 8
Android Question

Android studio 3.0 beta 3.2 canary: Multiple dex files define Lcom/google/android/gms/internal/zzasy;

I update android-studio 3.0 from canary 6 to beta 3.2 and suddenly it stop throwing multiple dex issue. And I have already handled multiple dex configuration according to this link: https://developer.android.com/studio/build/multidex.html
Also updated build tool version to 26.0.1 and all firebase and play service has same version which 11.2.0

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define
Lcom/google/android/gms/internal/zzasy;
Error:com.android.dex.DexException: Multiple dex files define
Lcom/google/android/gms/internal/zzasy;
Error: at
com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at
com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error: at
com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error: at
com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at
com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at
com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at
java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzass;
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzass;
Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error: at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error: at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at
com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at
com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task
':app:transformDexArchiveWithDexMergerForAkashDebug'.
> com.android.build.api.transform.TransformException:
com.android.dex.DexException: Multiple dex files define
Lcom/google/android/gms/internal/zzasy;

Answer Source

This is due to an update in the play services dependencies. With Android Studio 3.0 and above, google dependencies have moved to maven.google.com. Also, it is now recommended that you use module level dependencies. For eg: implementation 'com.google.android.gms:play-services-places:11.2.0' For more info on this check this

  • So move all your dependencies to module level dependencies with v11.2.0 Add this to your build.gradle

    repositories {
       mavenCentral()
       google()
     }
    
  • Replace all your compile statement to implementation

  • Delete your .idea folder in the project and rebuild. Everything should work fine then.