0

我在 android studio 项目中使用了一些库,但出现错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/kxml2/io/KXmlParser.class

我将 mapsforge & graphhopper 库和 ksoap2 jar 文件用于 Web 服务。这是 build.gradle (app) 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.mosa.palnav"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

}

dependencies {
//   compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile('com.graphhopper:graphhopper:0.6-SNAPSHOT') {
    exclude group: 'com.google.protobuf', module: 'protobuf-java'
    exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
    exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}
compile 'org.mapsforge:mapsforge-core:0.6.0'
compile 'org.mapsforge:mapsforge-map:0.6.0'
compile 'org.mapsforge:mapsforge-map-android:0.6.0'
compile 'org.mapsforge:mapsforge-map-reader:0.6.0'
compile 'org.slf4j:slf4j-android:1.7.12'
compile 'org.slf4j:slf4j-api:1.7.12'

compile files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
}

如何解决这个问题呢 ?

4

1 回答 1

0

I think you need to add a few more exclusions to your packagingOptions:

android {
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/DEPENDENCIES.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'
}

}

于 2016-01-25T17:22:18.760 回答