com.android.dex.DexException: Multiple dex files define

后端 未结 5 644
暗喜
暗喜 2021-01-01 10:05

I am using Android Studio 0.4.2. Opened project from a friend who is using 0.3.2. Tried to compile but got exception.

Execution failed for task \':JuiceTV:d         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-01 10:43

    As of Android Gradle 1.0 this can happen a few ways:

    1. If you only use Maven repos you can run into this issue if two different artifacts include the same class file.
      The Mockito-all library, for instance, includes Hamcrest and you would therefore cause this error if you included both dependencies in a build.
      Note, if you have minification turned on you won't see the error until you start using Hamcrest. The way to resolve this is to use a version of the library that isn't including other package's classes (Mockito-core in this case).

    2. If you declare a local jar/aar dependency (compile 'com.some.library:some-artiface-version_number@aar') that is already being included by other maven-based dependencies.
      In this situation your local declaration doesn't get de-duped with the Maven one because the pom information isn't available. You would typically create a local, file-based maven repo for the aar to get around this.

    In either case, a project clean is required to pickup the changes.

提交回复
热议问题