title: BuildConfig has already been added to output. Please remove duplicate copies. Android
body: <p>I have an Android project that uses gradle with library project as dependency.Dependency project has same package name as project.When I try to build the project but failed.</p>
  
  <p>Here is the folder structure with files in question:</p>
  
  <p>Library AndroidMainifest.xml</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test"
      android:allowBackup="true"&gt;
  
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Library build.gradle:</p>
  
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
      enforceUniquePackageName false
      defaultConfig {
          minSdkVersion 9
          targetSdkVersion 21
          versionCode 1
          versionName "1"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      lintOptions {
          abortOnError false
      }
  
      dexOptions {
          preDexLibraries false
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.android.support:appcompat-v7:21.0.3'
  }
  </code></pre>
  
  <p>Project build.gradle:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
      enforceUniquePackageName false
      defaultConfig {
          applicationId "com.test"
          minSdkVersion 9
          targetSdkVersion 21
          versionCode 1
          versionName "1"
      }
  
      lintOptions {
          abortOnError false
      }
  
      dexOptions {
          preDexLibraries false
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
  
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile project(':testLib')
  }
  </code></pre>
  
  <p>Error Message :</p>
  
  <pre><code>Error:Class com.test.BuildConfig has already been added to output. Please remove duplicate copies.
  1 error; aborting
  
    Error Code:
      1
    Output:
      UNEXPECTED TOP-LEVEL EXCEPTION:
      java.lang.IllegalArgumentException: already added: Lcom/test/BuildConfig;
          at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
          at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
          at com.android.dx.command.dexer.Main.processClass(Main.java:732)
          at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
          at com.android.dx.command.dexer.Main.access$300(Main.java:83)
          at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
          at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
          at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
          at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
          at com.android.dx.command.dexer.Main.processOne(Main.java:632)
          at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
          at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
          at com.android.dx.command.dexer.Main.run(Main.java:246)
          at com.android.dx.command.dexer.Main.main(Main.java:215)
          at com.android.dx.command.Main.main(Main.java:106)
      1 error; aborting
  </code></pre>