我正在尝试在Android Studio中编译项目,但出现以下错误
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v13/app/FragmentCompat$FragmentCompatImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
跑步
$ gradle -q dependencies
产生以下结果
compile - Classpath for compiling the main sources.
+--- project :facebookSDK
+--- project :stripe
+--- project :paymentKitLibrary
+--- com.google.code.gson:gson:2.2.4
+--- com.google.android.gms:play-services:4.3.23
+--- com.android.support:appcompat-v7:+ -> 19.1.0
+--- com.squareup.picasso:picasso:2.2.0
+--- com.loopj.android:android-async-http:1.4.4
\--- com.android.support:support-v13:+ -> 19.1.0
\--- com.android.support:support-v4:19.1.0
这是我的gradle依赖项
dependencies {
compile project(':facebookSDK')
compile project(':stripe')
compile project(':paymentKitLibrary')
compile 'com.google.code.gson:gson:2.2.4'
compile ('com.google.android.gms:play-services:4.3.23'){
exclude module: 'support-v4'
}
compile ('com.android.support:appcompat-v7:+'){
exclude module: 'support-v4'
}
compile 'com.squareup.picasso:picasso:2.2.0'
compile 'com.loopj.android:android-async-http:1.4.4'
compile "com.android.support:support-v13:+"
compile files('libs/crashlytics.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
compile files('libs/MobileAppTracker.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
}
我不明白冲突从何而来。是否有可能来自其中一个jar文件?到底是什么问题?
谢谢
最佳答案
我认为问题是在依赖项中两次声明了类“android.support.v13.app.FragmentCompat $ FragmentCompatImpl”。该类包含在以下两个依赖项中:
compile ('com.android.support:appcompat-v7:+'){
exclude module: 'support-v4'
}
compile "com.android.support:support-v13:+"
“support-v13”库已经包含“appcompat-v7”库。
尝试从“build.gradle”文件中删除“appcompat-v7”库,它应该可以编译。
// *** remove this ****
compile ('com.android.support:appcompat-v7:+'){
exclude module: 'support-v4'
}
希望这可以帮助。
关于android - 多个dex文件定义了Landroid/support/v13/app,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23278307/