title: Android Studio: Multiple dex files define Lcom/sun/activation/registries/LineTokenizer;
body: <p>Receiving this exception whilst trying to build my project. Have searched around for an answer but most cases seem to be different to mine. </p>
  
  <p>Other solutions include clearing temporary files or doing a gradle clean. This does temporarily solve the issue but it reappears again after a few builds. Another way this issue can occur is if the project contains multiple copies of a library. I have searched through my project and only have one instance of activation.jar which is in my libs directory. Most other solutions seem to involve changing the build path in Eclipse, but my problem is occurring on Android Studio 0.5.8. I am using Java 1.7.</p>
  
  <p><strong>Gradle Console</strong></p>
  
  <blockquote>
    <p>UNEXPECTED TOP-LEVEL EXCEPTION:       com.android.dex.DexException:
    Multiple dex files define
    Lcom/sun/activation/registries/LineTokenizer;
              at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
              at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
              at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
              at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
              at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
              at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
              at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
              at com.android.dx.command.dexer.Main.run(Main.java:230)
              at com.android.dx.command.dexer.Main.main(Main.java:199)
              at com.android.dx.command.Main.main(Main.java:103)</p>
  </blockquote>
  
  <p><strong>Libraries in libs dir:</strong></p>
  
  <ul>
  <li>activation.jar </li>
  <li>additionnal.jar </li>
  <li>androidplot-core-0.5.1.jar</li>
  <li>annotations.jar </li>
  <li>DatawindAdsSdk-2.0.jar </li>
  <li>jpct_ae.jar </li>
  <li>jsr305-1.3.9.jar</li>
  <li>libGoogleAnalyticsV2.jar </li>
  <li>mail.jar </li>
  <li>twitter4j-core-3.0.5.jar</li>
  </ul>
  
  <p><strong>Dependencies:</strong> Note - ":android-cropimage" does not have any dependencies in build.gradle</p>
  
  <p>Main module:</p>
  
  <pre><code>dependencies {
      //Library Projects
      compile project(':android-cropimage')
      compile project(':facebook')
  
      //Android SDK Libraries
      //This library requires "Google Play Services" and "Google Repository" to be downloaded via SDK Manager.
      compile 'com.google.android.gms:play-services:4.4.52'
  
      //Third Party
      compile fileTree(dir: 'libs', include: '*.jar')
      compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
      compile 'com.jakewharton:butterknife:4.0.1'
      compile 'com.j256.ormlite:ormlite-core:4.46'
      compile 'com.j256.ormlite:ormlite-android:4.46'
      compile 'net.hockeyapp.android:HockeySDK:3.0.1'
      compile 'org.apache.httpcomponents:httpmime:4.2.5'
      compile 'com.viewpagerindicator:library:2.4.1@aar'
      compile 'com.squareup.picasso:picasso:2.2.0'
      compile 'com.mcxiaoke.volley:library:1.0.+'
      compile 'org.msgpack:msgpack:0.6.11'
  }
  </code></pre>
  
  <p>Facebook module:</p>
  
  <pre><code>dependencies {
      compile 'com.android.support:support-v4:19.1.0'
  }
  </code></pre>