多个dex文件定义Lcom / google / android / gms / common / internal / zzag

时间:2017-08-24 14:31:52

标签: android google-play-services firebase-cloud-messaging

要获取当前位置,为此我创建了一个库项目并在那里插入两个依赖项。

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

更新我的项目以支持Firebase Cloud Messaging后,我收到此错误。

简而言之,

    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;

这是我的项目级别,

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

并且在我的应用级别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'

谢谢

1 个答案:

答案 0 :(得分:1)

做一件事,

在你的app level gradle中,对此行进行评论并尝试。

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