please consider that I'm not very familiar with Android development.
Trying to generate the Android signed bundle for my React Native app, I've stumbled upon the following error:
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
- I'm aware that
BrushType
is a class fromreact-native-svg
- I've ran
gradlew app:dependencies
and found no module depending onBrush
or anything related tocom.horcrux.svg
orreact-native-svg
- Already tried cleaning project, deleting
.iml
files, invalidating Android Studio caches, rebuilding, reinstallingnode_modules
and so on - Tried messing with
build.gradle
andgradle.properties
with no luck - I've read through this android guide on duplicate classes also with no luck
I understand that there are 2 or more dependencies utilizing com.horcrux.svg.Brush$BrushType
but I can't find them. I imagine that once I find them, I could do
implementation(:my-library) {
exclude ...
}
Correct?
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
}
}
Thanks in advance.
EDIT:
Solved by adding:
implementation(project(':react-native-jitsi-meet')) {
...
exclude group: 'com.facebook.react',module:'react-native-svg'
...
}
In my case it was react-native-jitsi-meet
that was causing the conflicts, I had to find it via trial and error.