title: DexException Multiple dex files define in Android
body: <p>In my android project am using two JAXB libraries jaxp-ri (for XMLGregorianCalendarImpl class) and jaxb-api(for object to xml conversion). I have added these two libraries in build.gradle file.</p>
  
  <p>But when I building my project am getting below mentioned errors</p>
  
  <pre><code>Error:Error converting bytecode to dex:
  Cause: com.android.dex.DexException: Multiple dex files define Ljavax/xml/stream/events/Namespace;
  Error:com.android.dex.DexException: Multiple dex files define Ljavax/xml/stream/events/Namespace;
  Error:  at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
  Error:  at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
  Error:  at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
  Error:  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
  Error:  at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
  Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
  Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
  Error:  at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
  Error:  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
  Error:  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
  Error:  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
  Error:  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
  Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
  &gt; com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Ljavax/xml/stream/events/Namespace;
  </code></pre>
  
  <p>Build.gradle file</p>
  
  <pre><code>dependencies {
  
      implementation fileTree(include: ['*.jar'], dir: 'libs')
  
      implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
  
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  
      testImplementation 'junit:junit:4.12'
  
      androidTestImplementation 'com.android.support.test:runner:1.0.1'
  
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  
      compile group: 'com.sun.org.apache', name: 'jaxp-ri', version: '1.4'
  
      compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1'
  
  }
  </code></pre>
  
  <p>can any one please help on this? how can I solve this problem?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Complete build.gradle file</p>
  
  <pre><code>android {
      compileSdkVersion 26
      defaultConfig {
          applicationId "in.cdac.xmlparsing"
          minSdkVersion 15
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          multiDexEnabled true
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
      implementation 'com.android.support.constraint:constraint-layout:1.0.2'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.1'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
      compile group: 'com.sun.org.apache', name: 'jaxp-ri', version: '1.4'
      compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1'
  }
  </code></pre>