I am working on upgrading a React Native application that uses @react-navigation/drawer
in package.json
As I got from the docs, it requires react-native-gesture-handler
and react-native-reanimated
to also be installed. I've done that and they look like this in my package.json:
"react-native": "0.70.7",
"@react-navigation/drawer": "^6.6.2",
"react-native-gesture-handler": "^2.9.0",
"react-native-reanimated": "^3.0.0",
The app compiles perfectly in debug mode and loads up fine in the emulator. However, when I'm trying to create an APK and run the commands ./gradlew clean && ./gradlew assembleStagingRelease
, I'm getting the following error:
* What went wrong:
Execution failed for task ':app:mergeDexStagingRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> 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.
Type com.swmansion.common.GestureHandlerStateManager is defined multiple times: /projects/rn/node_modules/react-native-reanimated/android/build/.transforms/dc7ef865db1cba58c97e7dd5333dfa60/transformed/release/com/swmansion/common/GestureHandlerStateManager.dex, /projects/rn/android/app/build/intermediates/external_libs_dex/stagingRelease/mergeExtDexStagingRelease/classes3.dex
I've been stuck on this for a while and not sure of the fix. Upon searching into node_modules, I see the interface GestureHandlerStateManager
is defined twice: one in reanimated package and one in gesture-handler package. It appears both packages are needed by the drawer package, so I can't delete any of them.