我正在尝试在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文件?无论如何,问题是什么?
由于
答案 0 :(得分:1)
我认为问题是该类" 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"库。
尝试删除" appcompat-v7"您的" build.gradle"中的库文件,它应该编译。
// *** remove this ****
compile ('com.android.support:appcompat-v7:+'){
exclude module: 'support-v4'
}
希望这有帮助。