请考虑我对Android开发不是很熟悉。
尝试为我的React Native应用生成Android签名的捆绑包时,我偶然发现了以下错误:
CompanyName
- 我知道
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
文件,使Android Studio缓存无效,重建,重新安装.iml
等 - 尝试与
node_modules
和build.gradle
混在一起,没有运气 - 我也没有碰过this android guide on duplicate classes,
我知道利用gradle.properties
有2个或更多的依赖项,但是我找不到它们。我想一旦找到它们,我就能做到
com.horcrux.svg.Brush$BrushType
正确吗?
gradle.properties
implementation(:my-library) {
exclude ...
}
android / app / build.gradle
android.useAndroidX=true
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m
谢谢。
编辑:
添加以下内容即可解决:
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'
...
}
导致了冲突,我不得不通过反复试验来找到它。