title: Gradle - DexException: Multiple dex files define
body: <p>I know this question has been asked already but I cannot find a suitable answer for my problem among the available solutions. I hope you guys can help me out.</p>
  
  <p>The exception tells that <code>Multiple dex files defined</code> and I tried several common ways to fix this problem. Unfortunately, this didn't help.</p>
  
  <pre><code>* What went wrong:
  Execution failed for task ':app:transformClassesWithDexForDebug'.
  &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
  
  
  
  Cause: com.android.dex.DexException: Multiple dex files define Lnet/jcip/annotations/GuardedBy;
          UNEXPECTED TOP-LEVEL EXCEPTION:
          com.android.dex.DexException: Multiple dex files define Lnet/jcip/annotations/GuardedBy;
              at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
              at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
              at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
              at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
              at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
              at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
              at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
              at com.android.dx.command.dexer.Main.run(Main.java:277)
              at com.android.dx.command.dexer.Main.main(Main.java:245)
              at com.android.dx.command.Main.main(Main.java:106)
  </code></pre>
  
  <ol>
  <li><p><strong>I tried to clean and rebuild the project.</strong></p>
  
  <ul>
  <li>Build -> Clean Project</li>
  <li>Build -> Rebuild Project</li>
  </ul></li>
  <li><p><strong>Then I tried to Invalidate Caches and Restart.</strong></p>
  
  <ul>
  <li>File -> Invalidate Caches and Restart</li>
  </ul></li>
  <li><p><strong>I also run this command to understand the duplications in dependencies:</strong></p>
  
  <blockquote>
    <p>./gradlew -q dependencies app:dependencies --configuration compile --stacktrace</p>
  </blockquote></li>
  </ol>
  
  <p>and here is the output. As you can see there are no duplications.</p>
  
  <pre><code>+--- com.jakewharton.hugo:hugo-annotations:1.2.1
  +--- com.google.code.findbugs:annotations:3.0.1
  |    +--- net.jcip:jcip-annotations:1.0
  |    \--- com.google.code.findbugs:jsr305:3.0.1
  +--- com.michaelpardo:activeandroid:3.1.0-SNAPSHOT
  +--- com.android.support:appcompat-v7:23.1.1
  +--- com.crashlytics.sdk.android:crashlytics:2.3.0
  |    +--- com.crashlytics.sdk.android:crashlytics-core:2.3.0
  |    |    \--- io.fabric.sdk.android:fabric:1.3.1
  |    +--- io.fabric.sdk.android:fabric:1.3.1
  |    \--- com.crashlytics.sdk.android:beta:1.1.2
  |         \--- io.fabric.sdk.android:fabric:1.2.0 -&gt; 1.3.1
  +--- com.greenhalolabs:emailautocompletetextview:1.3.0
  +--- com.facebook.android:facebook-android-sdk:4.2.0
  |    \--- com.parse.bolts:bolts-android:1.2.0
  +--- com.android.support:cardview-v7:23.1.1
  +--- com.jakewharton.hugo:hugo-runtime:1.2.0
  |    +--- com.jakewharton.hugo:hugo-annotations:1.2.0 -&gt; 1.2.1
  |    \--- org.aspectj:aspectjrt:1.8.5
  +--- joda-time:joda-time:2.0
  +--- io.keen:keen-client-api-android:2.1.2
  +--- com.googlecode.libphonenumber:libphonenumber:6.3.1
  +--- net.simonvt.menudrawer:menudrawer:3.0.6
  +--- com.squareup:otto:1.3.0
  +--- com.google.android.gms:play-services-base:8.4.0
  |    \--- com.google.android.gms:play-services-basement:8.4.0
  +--- com.google.android.gms:play-services-analytics:8.4.0
  +--- com.google.android.gms:play-services-gcm:8.4.0
  |    \--- com.google.android.gms:play-services-measurement:8.4.0
  +--- com.jeremyfeinstein.slidingmenu:library:1.3
  +--- com.android.support:support-v4:23.1.1
  |    \--- com.android.support:support-annotations:23.1.1
  +--- com.jakewharton.timber:timber:3.1.0
  +--- com.viewpagerindicator:library:2.4.1
  +--- com.ouralabs:ouralabs:2.7.0
  +--- com.android.support.test.espresso:espresso-idling-resource:2.2.1
  +--- project :domain
  |    \--- joda-time:joda-time:2.0
  \--- project :remote
       +--- com.squareup.retrofit:retrofit:1.6.0
       |    \--- com.google.code.gson:gson:2.2.4
       +--- com.squareup.okhttp:okhttp:2.4.0
       |    \--- com.squareup.okio:okio:1.4.0
       \--- com.squareup.okhttp:okhttp-urlconnection:2.4.0
  </code></pre>
  
  <ol start="4">
  <li><strong>I also read about the <code>multiDexEnabled true</code> but I'm sure that I didn't exceed the methods limit. This issue appeared instantly and without adding any libraries. I even can't assemble the older production versions of the code. They are in production and absolutely compilable.</strong></li>
  </ol>
  
  <p>Module's build.gradle:</p>
  
  <pre><code>dependencies {
      apply plugin: 'idea'
  
      compile "com.michaelpardo:activeandroid:${rootProject.ext.activeandroid}"
      compile(group: 'com.google.code.findbugs', name: 'annotations', version: "${rootProject.ext.findbugs}") {
          exclude(group: 'net.jcip', module: 'jcip-annotations')
      }
      compile(group: 'com.android.support', name: 'appcompat-v7', version: "${rootProject.ext.supportv4}") {
          exclude(group: 'com.android.support', module: 'support-v4')
      }
      compile(group: 'com.crashlytics.sdk.android', name: 'crashlytics', version: "${rootProject.ext.crashlytics}") {
          exclude(group: 'com.crashlytics.sdk.android', module: 'answers')
      }
      compile "com.greenhalolabs:emailautocompletetextview:${rootProject.ext.emailautocomplete}"
      compile(group: 'com.facebook.android', name: 'facebook-android-sdk', version: "${rootProject.ext.facebook}") {
          exclude(group: 'com.android.support', module: 'support-v4')
      }
      compile "com.android.support:cardview-v7:${rootProject.ext.supportv4}"
      compile "com.jakewharton.hugo:hugo-runtime:${rootProject.ext.hugo}"
      compile "joda-time:joda-time:${rootProject.ext.jodatime}"
      compile "io.keen:keen-client-api-android:${rootProject.ext.keen}"
      compile "com.googlecode.libphonenumber:libphonenumber:${rootProject.ext.libphonenumber}"
      compile "net.simonvt.menudrawer:menudrawer:${rootProject.ext.menudrawer}"
      compile "com.squareup:otto:${rootProject.ext.otto}"
      compile(group: 'com.google.android.gms', name: 'play-services-base', version: "${rootProject.ext.playservices}") {
          exclude(group: 'com.android.support', module: 'support-v4')
      }
      compile(group: 'com.google.android.gms', name: 'play-services-analytics', version: "${rootProject.ext.playservices}") {
          exclude(group: 'com.google.android.gms', module: 'play-services-basement')
      }
      compile(group: 'com.google.android.gms', name: 'play-services-gcm', version: "${rootProject.ext.playservices}") {
          exclude(group: 'com.google.android.gms', module: 'play-services-base')
          exclude(group: 'com.google.android.gms', module: 'play-services-basement')
      }
      compile "com.jeremyfeinstein.slidingmenu:library:${rootProject.ext.slidingmenu}"
      compile "com.android.support:support-v4:${rootProject.ext.supportv4}"
      compile "com.jakewharton.timber:timber:${rootProject.ext.timber}"
      compile "com.viewpagerindicator:library:${rootProject.ext.viewpagerindicator}"
      compile "com.ouralabs:ouralabs:${rootProject.ext.ouralabs}"
      compile "com.android.support.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"
  
      compile project(':domain')
      compile(project(':remote')) {
          exclude module: 'domain'
      }
  
      // Local Unit testing
      testCompile "junit:junit:$rootProject.ext.junit"
      testCompile "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
      testCompile "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
  
      // Instrumentation Testing
      androidTestCompile "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
      androidTestCompile "com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
      androidTestCompile "com.android.support.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
      androidTestCompile "com.android.support.test.uiautomator:uiautomator-v18:$rootProject.ext.uiautomator"
      androidTestCompile "com.android.support.test:runner:$rootProject.ext.runnerVersion"
      androidTestCompile "com.android.support.test:rules:$rootProject.ext.runnerVersion"
      androidTestCompile "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"
      androidTestCompile "com.google.dexmaker:dexmaker:$rootProject.ext.dexmaker"
      androidTestCompile "com.google.dexmaker:dexmaker-mockito:$rootProject.ext.dexmaker"
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I checked the project for <code>GuardedBy</code>. Is it looks like duplication?</p>
  
  <p><a href="https://i.stack.imgur.com/Wrp7v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wrp7v.png" alt="enter image description here"></a></p>