If you develop with Android studio and you want to use other projects as the library, the problem is very easy to come by. This problem occurs because of a duplicate reference to the package, which means that a package is referenced in your own project, and that the same package is referenced by your project as the library.
So how to fix it, all I know is there are two ways to do it:
Method 1: in accordance with the Convention, directly, from can see I have added a V4 in the library, and I use it as a dependencies, and in samples also have a V4 package, The same also needs to be used as a dependencies, this time you go to compile will have a duplicate reference problem:
How to solve it?
You can modify the Gradle file directly, or you can change it in, as shown in:
In the Gradle file, just change the compile to provided.
If configured directly, the same is true, select provided in the drop-down box. As you can explain here, you just have to change one of the items.
Method 2:
There is a premise to use this method, that is, the package you quoted in the library dependency, or take V4 package for example.
First of all, remove the V4 package from your Libs file, delete all two items, and then add the reference again, this way, directly, by the circled Red box operation:
In the popup dialog box, select the V4 package:
Click OK. Note that the two projects here need to be changed into this way to introduce the V4 package.
At this time, you can use the scope of the two V4 package that you introduced to compile. You don't need to change one of these to provided to compile. Of course, you can also not use the above graphical operation, directly in the Gradle file is also the same write.
Android Studio com.android.dex.DexException:Multiple dex files define (duplicate reference package)