请考虑我对Android开发不是很熟悉。
尝试为我的 React Native 应用程序生成 Android 签名包时,我偶然发现了以下错误:
Task :app:mergeDexRelease FAILED
D8: Program type already present: com.horcrux.svg.Brush$BrushType
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at
https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.horcrux.svg.Brush$BrushType
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.horcrux.svg.Brush$BrushType
- 我知道这
BrushType
是一个类react-native-svg
- 我跑了
gradlew app:dependencies
,发现没有模块依赖于Brush
或与com.horcrux.svg
或相关的任何东西react-native-svg
- 已经尝试过清理项目、删除
.iml
文件、使Android Studio缓存失效、重建、重新安装node_modules
等 - 尝试弄乱
build.gradle
并gradle.properties
没有运气 - 我已经阅读了这个关于重复类的 android 指南,也没有运气
我知道有 2 个或更多依赖项在使用com.horcrux.svg.Brush$BrushType
,但我找不到它们。我想一旦我找到它们,我就可以做到
implementation(:my-library) {
exclude ...
}
正确的?
gradle.properties
android.useAndroidX=true
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m
android/app/build.gradle
dependencies {
implementation project(':react-native-appearance')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':watermelondb')
implementation project(':react-native-calendar-events')
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(project(':react-native-jitsi-meet')) {
...
exclude group: 'com.facebook.react',module:'react-native-svg'
...
}
就我而言,react-native-jitsi-meet
这是导致冲突的原因,我必须通过反复试验找到它。