gpt4 book ai didi

android - 多个dex文件定义Lorg/apache/commons/logging/impl/LogFactoryImpl

转载 作者:行者123 更新时间:2023-11-29 02:32:03 25 4
gpt4 key购买 nike

正如标题所说,正在定义多个 dex 文件,我一直在寻找如何解决这个问题,但没有运气,所以我决定接触社区,长话短说,我是将这个遗留项目的 gradle 构建系统从 gradle 0+ 更新到 gradle 3+,我设法重构了常见的配置,例如 flavoring、依赖项(从编译到 api/implementation)、(你的名字......),直到我迷迷糊糊在这个dex问题上,我首先想到的是借助Using gradle to find dependency tree打破依赖关系。 ,但不幸的是,它在 gradlew 命令上花费了我太多时间,并且仍然以 gradlew 问题结束(无法执行 AndroidSdk 的东西),所以我退后一步(以尽量减少我需要的时间)并这样做......(播放赔率)

dependencies {

api (project(':<omitted project name>')) {
exclude group: 'org.apache.commons', module: 'logging'
}

api (project(':<omitted project name>')) {
exclude group: 'org.apache.commons', module: 'logging'
}

implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:design:23.1.0'

implementation ('com.google.code.gson:gson:2.3'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.squareup.picasso:picasso:2.5.2'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.squareup.okhttp:okhttp:2.4.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('org.bitbucket.b_c:jose4j:0.5.2'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation (group: 'commons-io',name:'commons-io',version: '2.0.1'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation (group: 'com.jcraft', name: 'jsch', version: '0.1.44-1'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.android.support:design:23.1.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.android.support:appcompat-v7:24.2.1'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.facebook.android:facebook-android-sdk:4.10.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.google.android.gms:play-services:9.8.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.google.android.gms:play-services-gcm:9.0.1'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.google.android.gms:play-services-auth:9.8.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.github.PhilJay:MPAndroidChart:v3.0.2'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation (group: 'org.apache.commons', name: 'commons-compress', version: '1.3') {
exclude group: 'org.apache.commons', module: 'logging'
}

implementation (group: 'org.apache.commons', name: 'commons-vfs2', version: '2.2') {
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
exclude group: 'org.apache.commons', module: 'logging'
}

api fileTree(dir: 'libs', include: ['*.jar'])
api files('libs/nfc7003.jar')
api files('libs/minilcd7003.jar')
api files('libs/Scan7003.jar')
api files('libs/UserInterface.jar')
api files('libs/printer7003.jar')
}

我无法弄清楚上面列表中谁的依赖项与日志框架有这个传递问题,我对它们都定义了一个排除项,仍然没有运气..

只是提一下背后的原因:我需要 Android studio 3 的高级分析,并且必须使用最新的 gradle(4+)/build tool(3+) 才能做到这一点,这让我来到这里。 .

请帮我解决这个问题,在此先感谢...

[编辑] 构建消息:

 Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define
Lorg/apache/commons/logging/impl/LogFactoryImpl$2;
Error:com.android.dex.DexException: Multiple dex files define
Lorg/apache/commons/logging/impl/LogFactoryImpl$2;
Error: at
com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at
com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error: at
com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error: at
com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error: at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error: at
com.android.builder.dexing.
DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error: at
com.android.builder.dexing.
DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error: at java.util.concurrent.
ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error: at
java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error: at
java.util.concurrent.
ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error: at
java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error: at
java.util.concurrent.
ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task '
:<omitted project name>:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException:
com.android.dex.DexException: Multiple dex files define
Lorg/apache/commons/logging/impl/LogFactoryImpl$2;

最佳答案

问题是因为您在 build.gradle 中使用了重复的库。

首先,对于支持库,你需要使用相同的版本。不要使用以下内容:

implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:design:23.1.0'

implementation ('com.android.support:design:23.1.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.android.support:appcompat-v7:24.2.1'){
exclude group: 'org.apache.commons', module: 'logging'
}

改为使用以下内容:

implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:design:25.4.0'

// appcompat is implicitly include within support design.

其次,对于google play服务,使用相同的版本。不要使用以下内容:

implementation ('com.google.android.gms:play-services:9.8.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.google.android.gms:play-services-gcm:9.0.1'){
exclude group: 'org.apache.commons', module: 'logging'
}

implementation ('com.google.android.gms:play-services-auth:9.8.0'){
exclude group: 'org.apache.commons', module: 'logging'
}

改为使用:

// Dont use the whole play service library
//implementation 'com.google.android.gms:play-services:9.8.0'
implementation 'com.google.android.gms:play-services-gcm:9.8.0'
implementation 'com.google.android.gms:play-services-auth:9.8.0'

第三,要排除常见日志记录,您需要使用如下内容:

compile(group: 'org.apache.commons', name: 'commons-compress', version: '1.3'){
exclude group: 'commons-logging', module: 'commons-logging'
}

或使用以下内容:

configurations.all {
exclude group: "commons-logging", module: "commons-logging"
}

您不需要向每个库添加排除项,因为某些库内部没有任何公共(public)日志记录。

关于android - 多个dex文件定义Lorg/apache/commons/logging/impl/LogFactoryImpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49144242/

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