title: Android Gradle App and Libraries jar conflicts
body: <p>I want to migrate a big application from Ant to Gradle.
  Since the app has been (wrongly) created as several libraries, the first migration will keep the same Modules (it will refactored in a second step) and it will probably end up in this structure:</p>
  
  <pre>
  
      -- Project/
             |-- App/
                    |-- libs/
                    |-- src/...
                    |-- build.gradle
             |-- Module1/
                    |-- libs/
                           |-- lib1.jar
                           |-- lib2.jar
                    |-- src/...
                    |-- build.gradle
             |-- Module2/
                    |-- libs/
                           |-- lib2.jar
                           |-- lib3.jar
                    |-- src/...
                    |-- build.gradle
           build.gradle
           settings.gradle
  
  </pre>
  
  <p>The App build.gradle is something like this:</p>
  
  <pre>
  
      ...
  
      apply plugin: 'com.android.application'
  
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile 'com.android.support:support-v4:20.0.0'
          compile 'com.android.support:appcompat-v7:20.0.0'
  
          compile project(':Module1')
          compile project(':Module2')
      }
  
      ...
  
  </pre>
  
  <p>And then each Module build.gradle will be something like this:</p>
  
  <pre>
  
      ...
  
      apply plugin: 'com.android.library'
  
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile 'com.android.support:support-v4:20.0.0'
          compile 'com.android.support:appcompat-v7:20.0.0'
      }
  
      ...
  
  </pre>
  
  <p>Every module compiles correctly, but the problem happens when building the APK, because lib2.jar is copied 2 times, resulting on an error:</p>
  
  <p>Error:Gradle: Execution failed for task ':app:packageDebug'.</p>
  
  <blockquote>
    <p>Duplicate files copied in APK META-INF/ASL2.0
    and then the path to the 2 JARs.</p>
  </blockquote>
  
  <p>How can I tell Gradle to do not copy multiple times the same JARs when building the APK from each module?
  At this moment, I cannot move dependencies to Maven central repo, even if I will in the future.
  Maybe adding all the libs in the parent App? It does not look very nice to me... And in this case, how can I specify that dependencies in the build.gradle Modules?</p>