Android Studio com. android. dex. DexException: Multiple dex files define (repeated reference package), androiddefine

Source: Internet
Author: User

Android Studio com. android. dex. DexException: Multiple dex files define (repeated reference package), androiddefine

If you use Android Studio for development and use other projects as libraries, this problem is very easy to occur. This problem occurs because the package is repeatedly referenced, which means that a package is referenced in your own project, and the same package is referenced by your project as a library, this problem occurs.

So how can we solve it? What I know is that there are two methods:

Method 1: Follow the conventions. You can see that I have added a v4 package to the library and use it as dependencies, in samples, there is also a v4 package, and it also needs to be used as dependencies. At this time, you will see repeated references when compiling:

How can this problem be solved?

You can directly modify the gradle file or change it in, as shown in:

In the gradle file, you only need to change compile to provided.

The same is true if you configure it directly. Select provided in the drop-down box. Here, you only need to change one of the projects.


Method 2:

There is a premise to use this method, that is, the package you reference is in the Library dependency, or take the v4 package as an example.

First, delete the v4 package from your libs file, delete both projects, and then re-add the reference. The method for adding the package is as follows:


In the displayed dialog box, select the v4 package:


Click OK. Note that this method must be used to introduce v4 packages for both projects.

At this time, the Scope of the v4 package introduced by you can use compile. You do not need to change one of them to provided for compilation. Of course, you can also directly write in the gradle file without the graphical operation method above.

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.