gpt4 book ai didi

android - Gradle中不排除Apache Commons依赖性安卓

转载 作者:行者123 更新时间:2023-12-03 05:12:28 25 4
gpt4 key购买 nike

我有一个使用org.apache.http.legacy库的库项目(Janrain:Jump)。当我尝试构建项目时,出现重复错误,如下所示:

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/codec/StringEncoderComparator.class

因此,我发现 org.apache.commons是重复条目,因为Janrain使用了它,并且它也包含在Android 24中(作为外部库)。所以我试图从:Jump gradle中删除公地,例如:
configurations {
all*.exclude group: 'org.apache.commons'
}

现在,我希望这会删除 org.apache.commons,但仍然会收到重复的条目gradle错误。

这是:Jump gradle文件
apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
//If building with strict Android 6.0 the following will need to be uncommented
//See: https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
//And: http://stackoverflow.com/questions/31653002/how-to-use-the-legacy-apache-http-client-on-android-m
useLibrary "org.apache.http.legacy"

defaultConfig {
minSdkVersion 17
targetSdkVersion 24
// replace the below string with your own Google client ID. Make sure this is consistent
// with the values used in openid_appauth_idp_configs.xml
manifestPlaceholders = [
<my values>]
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}

}
}

configurations {
all*.exclude group: 'org.apache.commons'
}

dependencies {
compile 'com.android.support:support-v4:24.2.0'
compile files('libs/org.apache.http.legacy.jar')
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-apache:2.5.0'
compile 'com.squareup.okio:okio:1.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'net.openid:appauth:0.4.1'
}

allprojects {
repositories {
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}

为什么即使我将 org.apache.commons包含在配置中也不排除它?

最佳答案

只需将此任务添加到build.gradle中,然后运行gradle findDuplicates即可找到 jar

task findDuplicates {
doLast {
def findMe = 'org/apache/commons/codec/StringEncoderComparator.class'
configurations.runtime.asFileTree.matching {
include '**/*.jar'
}.files.each { File jarFile ->
zipTree(jarFile).visit { FileVisitDetails fvd ->
if (fvd.path == findMe) {
println "Found $findMe in $jarFile.name"
}
}
}
}
}

关于android - Gradle中不排除Apache Commons依赖性安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42495348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com