Gradle文件包含以下依赖项
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'javax.xml.bind:jaxb-api:2.2.12'
implementation 'javax.xml.stream:stax-api:1.0-2'
implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation group: 'xerces', name: 'xercesImpl', version: '2.8.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents', module: 'commons-codec'
}
implementation('com.google.apis:google-api-services-gmail:v1-rev83-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
}
在其他多个多类错误中,commons-codec
在依赖关系树中具有以下用法
+--- com.google.api-client:google-api-client-android:1.23.0
| +--- com.google.api-client:google-api-client:1.23.0
| | +--- com.google.oauth-client:google-oauth-client:1.23.0
| | | +--- com.google.http-client:google-http-client:1.23.0
| | | | +--- com.google.code.findbugs:jsr305:1.3.9
| | | | \--- org.apache.httpcomponents:httpclient:4.0.1
| | | | +--- org.apache.httpcomponents:httpcore:4.0.1
| | | | +--- commons-logging:commons-logging:1.1.1
| | | | \--- commons-codec:commons-codec:1.3
\--- commons-codec:commons-codec:{strictly 1.3} -> 1.3 (c)
该问题可能与传递依赖有关,但是据我通过对依赖树的分析可以了解,只有org.apache.httpcomponents
将此问题用作库,但是由于某些原因,我无法理解,Gradle构建文件中的排除声明无法按预期工作。
与commons-codec
模块相关的Gradle构建日志
Duplicate class org.apache.commons.codec.BinaryDecoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.BinaryEncoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.Decoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.DecoderException found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.Encoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.EncoderException found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.StringDecoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.StringEncoder found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.StringEncoderComparator found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.binary.Base64 found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.binary.BinaryCodec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.binary.Hex found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.digest.DigestUtils found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.DoubleMetaphone found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.DoubleMetaphone$DoubleMetaphoneResult found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.Metaphone found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.RefinedSoundex found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.Soundex found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.language.SoundexUtils found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.net.BCodec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.net.QCodec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.net.QuotedPrintableCodec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.net.RFC1522Codec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
Duplicate class org.apache.commons.codec.net.URLCodec found in modules commons-codec-1.3.jar (commons-codec:commons-codec:1.3) and docx4j-6.1.1-SNAPSHOT-shaded.jar (docx4j-6.1.1-SNAPSHOT-shaded.jar)
请注意,docx4j-6.1.1-SNAPSHOT-shaded.jar
是添加到libs文件夹中的jar。不确定为什么这些jar文件没有显示在依赖关系树中。
答案 0 :(得分:0)
因此,通过排除所有传递依赖的实例,它起作用了
configurations {
all*.exclude group: 'commons-codec', module: 'commons-codec'
}
此方法是否有缺点?这样,难道不是google-api-client-android
模块中包含的所有方法都使用commons-codec
依赖项来使用docx4j-6.1.1-SNAPSHOT-shaded.jar
方法吗?这两个人不能使用commons-codec
模块的不同内部版本吗?