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

后端 未结 5 600
暗喜
暗喜 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:37

    This happens when a Module has a dependency on both another module and that same module's jar.

    0 讨论(0)
  • 2021-01-01 10:41

    I had this issue on android studio 1.0, along with removing the duplicate entry for libraries you should also try deleting the bin folders and do a clean build.

    0 讨论(0)
  • 2021-01-01 10:41

    Having multiDex disabled and incremental in dexOptions enabled will also cause this issue.

    defaultConfig {
        multiDexEnabled = false
     }
    dexOptions {
        javaMaxHeapSize "4g"
        incremental true
    }
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-01 10:48

    I just had the same issue and I discovered that my application and a library were referring to 2 versions of the same jar.

    I did a search and my application.iml file clearly showed the duplicates.

    <orderEntry type="library" exported="" name="crittercism_v3_0_11_sdkonly" level="project" />
    <orderEntry type="library" exported="" name="crittercism_v4_4_0" level="project" />
    

    I replaced the older v3 version with the v4 version and it worked after a clean rebuild.

    0 讨论(0)
提交回复
热议问题