【发布时间】:2021-04-21 18:16:46
【问题描述】:
我正在开发一个基于 react-native 的应用程序。 当我尝试编译我的应用程序时,我遇到了 Gradle 提出的重复类问题。
这是错误日志:
Execution failed for task ':app:checkLocalDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class org.apache.commons.io.ByteOrderMark found in modules commons-io-2.4.0.jar (org.lucee:commons-io:2.4.0) and commons-io-2.6.jar (commons-io:commons-io:2.6)
Duplicate class org.apache.commons.io.Charsets found in modules commons-io-2.4.0.jar (org.lucee:commons-io:2.4.0) and commons-io-2.6.jar (commons-io:commons-io:2.6)
... (and many more)
我查找了在线解决方案,我想从构建中排除一个依赖项,即较低版本的一个。这样,我认为构建将起作用。
我运行app:dependencies 来查找哪些包正在使用这个重复的依赖项:
--- com.facebook.react:react-native:+ -> 0.63.4
| ...
+--- project :expo-constants
| ...
| \--- commons-io:commons-io:2.6
+--- project :expo-file-system
| ...
| +--- commons-io:commons-io:1.4 -> 2.6
| ...
+--- com.bridgefy:android-sdk:1.1.28
| ...
| +--- org.lucee:commons-io:2.4.0
| ...
现在,我将其添加到我的 app/build.gradle 文件中:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
addUnimodulesDependencies()
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation 'com.android.support:multidex:1.0.3'
// I ADDED THIS LINE BELOW
implementation('com.bridgefy:android-sdk:1.1.28') {
exclude group: 'org.lucee', module: 'commons-io'
}
}
这个错误并没有消失......我认为模块没有被排除,但我认为这是方式。请问这个怎么解决?
【问题讨论】:
标签: android react-native gradle