title: Library dependency not working with module
body: <p>I'm using Android Studio. I have two modules: the app (UI) and a library. When tested separately, both compile and work as they should, but when I try to use some of the library classes on the app, I can't build the project. I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/DckZI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DckZI.png" alt="Android Studio screenshot of failed build"></a></p>
  
  <blockquote>
    <p>Error: Program type already present: org.apache.xmlbeans.xml.stream.Location</p>
  </blockquote>
  
  <p>My library <code>build.gradle</code> has just a few lines:</p>
  
  <pre><code>apply plugin: 'java-library'
  
  
  dependencies {
  
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'org.apache.poi:poi:3.17'
  implementation 'org.apache.poi:poi-ooxml:3.17'
  
  }
  
  sourceCompatibility = "7"
  targetCompatibility = "7"
  </code></pre>
  
  <p>Then my app's build.gradle is this</p>
  
  <pre><code>android {
  compileSdkVersion 28
  defaultConfig {
      applicationId "skrb.appprueba"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner 
  "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }
  }
  
  dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'com.android.support:appcompat-v7:28.0.0'
  implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  implementation 'com.android.support:support-v4:28.0.0'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  implementation 'com.android.support:design:28.0.0'
  implementation project(path: ':coreLib')
  
  }
  </code></pre>
  
  <p>When adding this (<code>implementation project(path: ':coreLib')</code>, I get the error and I don't know how to solve it.</p>
  
  <p>Things that I tried:</p>
  
  <ul>
  <li>Cleaning and rebuilding the project.</li>
  <li>Setting <em>multiDexEnabled</em> to <em>true</em></li>
  </ul>