Solve the Problem of repeated package loading when Android Studio loads third-party jar packages:

Source: Internet
Author: User
Tags maven central

Solve the Problem of repeated package loading when Android Studio loads third-party jar packages:

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: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;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.


<喎?http: www.bkjia.com kf ware vc " target="_blank" 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 ')}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'    compile ('in.srain.cube:cube-sdk:1.0.42.1'){        exclude module: 'support-v4'    }    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.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.