Android Studio loads third-party jar packages, and the following error occurs: androidjar
When a third-party jar package is added through the Maven Central Library, the problem of repeatedly loading the jar package occurs. The solution is to simply remove a third-party jar package and let it load it.
I. Error
Error:Execution failed for task ':app:dexDebug'.> com.android.ide.common.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.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)at com.android.dx.command.dexer.Main.run(Main.java:246)at com.android.dx.command.dexer.Main.main(Main.java:215)at com.android.dx.command.Main.main(Main.java:106)
From the above error, we can see that the support_v4 package has been repeatedly loaded and compiled. Let's take a look at the gradle-app file.
dependencies { 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'</span> compile files('libs/android-async-http-1.4.6.jar')}
After the v7 package is introduced, a v4: 21.0.0 package is automatically loaded and compiled. srain. the cube: cube-sdk: 1.0.42.1 Library also has a v4 package, so we need to remove
Check whether libraries reloads the v4 package as we said.
Ii. Solution
dependencies { 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')}
Remove the packages in. srain. cube: cube-sdk: 1.0.42.1 and do not load them.