Android studio:multiple dex Files define Landroid/support/annotation/animres

Source: Internet
Author: User

Recently really busy, accidentally blog and a desolate two months.

From today onwards, we decided to return to CSDN, to record and share.

First from a recently tortured and tormented problem.
Because the V4 package was upgraded. Have always reported this problem:

com.android.dex.DexExceptionMultiple dex files define Landroid/support/annotation/AnimRes;

Clean it every time, and then compile the talent. The process of light wasted 4/5 minutes. This problem arises because the latest V4 package (compile ' com.android.support:support-v4:22.2.1 ') already includes the Annotation.jar package, but this package is also included in the other jar packages. Not the same time including v4/v7 caused, so a bunch of people say in the V7 bag for example the following settings:

compile (‘com.android.support:appcompat-v7:22.2.1‘){        group"com.android.support""support-v4"    }

That is, set V7 package does not include V4, this set up is useless.

Just make sure that the local version number of V4 and V7 is the same.

The correct solutions are as follows:
1, find the other dependencies of the project. Must be in one of the jar bags in libs. Hide the Annotation.jar bag, delete it is OK. This is the most Orthodox solution.
2. Downgrade the V4 package. Because the v4 of the high version number includes Annotation.jar, it is possible to force the setting in the outermost build.grable:

{    repositories {        jcenter()    }    configurations.{        resolutionStrategy.force ‘com.android.support:support-annotations:22.1.0‘    }}

3, in the need to V4 bag exclude drop annotation bag. Note that compile will have to add a parenthesis:

 compile (‘com.android.support:support-v4:22.2.1‘){        module: ‘support-annotations‘    }

The disadvantage is that every place to use the V4 package is set.
4. Add a sentence in the Dexoptions setting in the application Build.gradle: Predexlibraries = False is OK:

PS: The above four methods are able to solve this problem, recommend Orthodox Method 1 and Lazy Method 4.

Android studio:multiple dex Files define Landroid/support/annotation/animres

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.