2016-01-25 44 views
0

我用在Android Studio中的項目 一些庫,但有一個錯誤:機器人工作室重複項:組織/ kxml2/IO/KXmlParser.class

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文件網頁服務。 這是的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') 
} 

如何解決這個問題呢?

回答

0

我認爲你需要幾個例外添加到您的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' 
} 

}

+0

不幸的是,這個問題仍然是 –