2016-05-17 9 views
2

Ich habe ein Android Studio-Projekt enthält zwei Module verwenden die gleiche Bibliothek (jsoup). Wenn ich Compie App zeige esZwei Module verwenden die gleiche Bibliothek in Android Studio

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/org.jsoup/jsoup/pom.xml File1: C:\Users\G.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup\1.8.2\64238922c4006c3d0a9951c4c03983ecc6a1e1a0\jsoup-1.8.2.jar File2: C:\Users\G\AndroidStudioProjects\twrb\app\build\intermediates\exploded-aar\twrb\webviewtimetablesearcher\unspecified\jars\classes.jar

Die Abhängigkeiten in build.gradle von zwei Modulen wie unten gezeigt.

dependencies { 
    compile 'org.jsoup:jsoup:1.8.2' 
} 

Und das ist build.gradle von app.

dependencies { 
    compile project(':moduleA') 
    compile project(':moduleB') 
} 

Wie es zu beheben ?? Vielen Dank.


Das ist meine ganze build.gradle von App

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "com.test.tmp" 
     minSdkVersion 15 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1" 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    packagingOptions { 
     exclude 'META-INF/services/javax.annotation.processing.Processor' 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/dependencies.txt' 
     exclude 'META-INF/LGPL2.1' 
     exclude 'META-INF/maven/org.jsoup/jsoup/pom.xml' 
     exclude 'org/jsoup/nodes/entities-base.properties' 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 
} 

buildscript { 
    repositories { 
     mavenCentral() 
    } 

    dependencies { 
     classpath 'me.tatarka:gradle-retrolambda:3.2.4' 
    } 
} 

// Required because retrolambda is on maven central 
repositories { 
    mavenCentral() 
} 

apply plugin: 'com.android.application' //or apply plugin: 'java' 
apply plugin: 'me.tatarka.retrolambda' 

dependencies { 
    compile 'com.android.support:support-v4:23.2.1' 
    compile 'com.android.support:appcompat-v7:23.1.0' 
    compile 'com.android.support:design:23.1.0' 
    compile 'com.android.support:cardview-v7:23.1.0' 
    compile 'com.android.support:recyclerview-v7:23.1.0' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'io.realm:realm-android:0.87.5' 
    compile 'de.greenrobot:eventbus:2.4.0' 
    compile 'io.reactivex:rxandroid:1.1.0' 
    compile 'io.reactivex:rxjava:1.1.0' 
    compile 'com.jakewharton.rxbinding:rxbinding:0.4.0' 
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' 
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' 
    testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' 
    testCompile 'junit:junit:4.12' 
    androidTestCompile 'junit:junit:4.12' 
    compile project(':moduleA') 
    compile project(':moduelB') 
} 

Antwort

3

Für resolve es Sie

android { 
    packagingOptions { 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
    } 
} 

in build.gradle

+0

Check http://stackoverflow.com/ müssen hinzufügen Fragen/33951853/com-android-bauen-api-transform-transformexception-com-android-builder-packagin –

+0

Danke für deine Antwort. Aber die doppelte Datei ist META-INF/maven/org.jsoup/jsoup/pom.xml. Ich habe versucht, "auszuschließen", aber zeigt eine andere doppelte Datei: org/jsoup/nodes/entities-base.properties. Wenn ich es ausschließe, wird es nicht funktionieren. So suche ich andere Lösung, um dieses Problem zu lösen. – aiueoH

+0

posten Sie Ihre Build.gradle der App. –

Verwandte Themen