-02-130 个评论 来源:JavAndroid 收藏 我要投稿 通过Maven中央库添加第三方jar包的时候,出现了重复加载jar包的问题,解决办法很简单去掉一个不让它去加载就OK了一、错误Error:Execution failed for task ':app:dexDebug'.> com.mon.internal.LoggedErrorException: Failed to run command:F:\zsl\sdk\build-tools\21.1.2\dx.bat --dex --output F:\zsl\Android\pro\RecipesDaquan\app\build\intermediates\dex\debug --input-list=F:\zsl\Android\pro\RecipesDaquan\app\build\intermediates\tmp\dex\debug\inputList.txtError Code:2Output:UNEXPECTED TOP-LEVEL EXCEPTION:com.android.dex.DexException:<strong> <span style="color:#3333ff;">Multiple dex files define Landroid/</span><span style="color:#ff0000;">support/v4</span><span style="color:#3333ff;">/accessibilityservice/AccessibilityServiceInfoCompatIcs;</span></strong>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.mand.dexer.Main.mergeLibraryDexBuffers(Main.java:454)at com.mand.dexer.Main.runMonoDex(Main.java:303)at com.mand.dexer.Main.run(Main.java:246)at com.mand.dexer.Main.main(Main.java:215)at com.mand.Main.main(Main.java:106)从上述错误中我们可以看到support_v4的包重复加载编译了,我们看一下gradle-app文件
class=”keylink”>vcD4KPHByZSBjbGFzcz0=”brush:java;”>dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) compile ‘com.android.support:appcompat-v7:21.0.0’ compile ‘in.srain.cube:cube-sdk:1.0.42.1’ compile files(‘libs/android-async-http-1.4.6.jar’) }其中引入了v7的包后会自动去加载编译一个v4:21.0.0包,而在in.srain.cube:cube-sdk:1.0.42.1库中也有一个v4的包,所以我们需要去掉一个
看一下,libraries是否是我们所讲的那样,重复加载v4包\\二、解决办法?12345678dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])compile 'com.android.support:appcompat-v7:21.0.0'<span style="color:#ff0000;">compile ('in.srain.cube:cube-sdk:1.0.42.1'){exclude module: 'support-v4'}</span>compile files('libs/android-async-http-1.4.6.jar')}去掉in.srain.cube:cube-sdk:1.0.42.1中的包不加载即可。