Jay Vyas Jay Vyas - 2 months ago 21
Android Question

Multiple dex files define Lcom/google/android/gms/common/internal/zzag

To fetch current location,for this I have created a library project and insert two dependencies there.

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


After updating my project to support Firebase Cloud Messaging I am getting this error.

In brief,

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/internal/zzag;
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/internal/zzag;
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:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/internal/zzag;


It's my project level gradle,

classpath 'com.google.gms:google-services:3.1.0'


and at my app level gradle,

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

compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'


Thank you

Answer Source

Do One thing,

In your app level gradle, comment this line and try.

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