android studio duplicate entry: org/kxml2/io/KXmlParser.clas



我在安卓工作室项目中使用了一些库但是有一个错误:

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(应用程序)文件:

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')
}

如何解决这个问题?

我认为您需要在包装中添加更多排除项选项:

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'
}

}

相关内容

  • 没有找到相关文章

最新更新