我正在尝试在Gradle项目中使用我的aar库(一个使用Jayway的android-maven-plugin构建的Maven项目),但是当我运行gradle assembleDebug
时,我遇到了以下异常:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/actions/ItemListIntents;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
如果我在我的项目中搜索该类,Android Studio会找到两个结果:
ListItemIntents (com.google.android.gms.action) play-services-base-7.0.0(classes.jar)
ListItemIntents (com.google.android.gms.action) aar-library(classes.jar)
运行检查gradle dependencyInsight --dependency play-services-base --configuration compile
,我得到:
com.google.android.gms:play-services-base:7.0.0
+--- com.google.android.gms:play-services-gcm:7.0.0
| \--- aar-library:core:1.0.10-SNAPSHOT
| \--- compile
+--- com.google.android.gms:play-services-location:7.0.0
| \--- com.nexse.mobile.betting.core:core:1.0.10-SNAPSHOT (*)
\--- com.google.android.gms:play-services-maps:7.0.0
\--- com.google.android.gms:play-services-location:7.0.0 (*)
(*) - dependencies omitted (listed previously)
问题出现在 aar-library 的
classes.jar
文件中:ListIntentIntents
(以及整个 play-services-base 模块)已经存在!因此,在其中。my-gradle-project/app/build/intermediates/exploded-aar/
我有两个关于play-services-base模块的引用:一个在com.google.android.gms
文件夹下,另一个在aar-library
文件夹下。
我该怎么办?