Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Execution failed for task ':app:mergeLibDexDebug'. RNGH conflicts with MMKV when fabric enabled #2382

Closed
devoren opened this issue Jan 17, 2023 · 9 comments
Labels
Missing info Missing repro Platform: Android This issue is specific to Android

Comments

@devoren
Copy link

devoren commented Jan 17, 2023

Description

I'm facing some difficulties in building my project with the new architecture enabled and disabled. I created new React Native app in version 0.71 and installed RN-GH. Please let me know if you are familiar with this issue and have resolved.

Build logs:
ERROR:C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex: D8: Type com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex, C:\Programs...\node_modules\react-native-mmkv\android\build.transforms\4dc488954a239fc51aa940d208820628\transformed\classes\classes.dex
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.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex, C:\Programs...\node_modules\react-native-mmkv\android\build.transforms\4dc488954a239fc51aa940d208820628\transformed\classes\classes.dex
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:151)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:138)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:859)
at com.android.build.gradle.internal.tasks.DexMergingWorkAction.run(DexMergingTask.kt:805)
...
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex
...
Caused by: com.android.tools.r8.internal.f: Type com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex, C:\Programs\rn\SM\node_modules\react-native-mmkv\android\build.transforms\4dc488954a239fc51aa940d208820628\transformed\classes\classes.dex
...
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeLibDexDebug'.

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.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: C:\Programs...\node_modules\react-native-gesture-handler\android\build.transforms\c4565ac0bfe4bc3cd8cc31ed594058d4\transformed\classes\classes.dex, C:\Programs...\node_modules\react-native-mmkv\android\build.transforms\4dc488954a239fc51aa940d208820628\transformed\classes\classes.dex

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.

  • What went wrong:
    java.lang.StackOverflowError (no error message)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

BUILD FAILED in 1m 8s

Steps to reproduce

  1. Init app
  2. yarn android
  3. Execution failed for task ':app:mergeLibDexDebug'.

Snack or a link to a repository

NA

Gesture Handler version

2.9.0

React Native version

0.71.0

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Android emulator

Device model

Pixel 4 API 31

Acknowledgements

Yes

@github-actions
Copy link

github-actions bot commented Jan 17, 2023

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro labels Jan 17, 2023
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@devoren devoren closed this as completed Jan 17, 2023
@sshestopalov
Copy link

@devoren, how did you solve the issue?

@devoren
Copy link
Author

devoren commented Jan 24, 2023

@sshestopalov after updating RN to version 0.71.1 the problem disappeared, but RNGH conflicts with react-native-MMKV

@sshestopalov
Copy link

@devoren yes, I have RNGH and react-native-mmkv in my project, that must the problem. thanks!

@dennisvk001
Copy link

Having the same conflict.

@devoren devoren reopened this Jan 26, 2023
@devoren devoren changed the title [Android] Execution failed for task ':app:mergeLibDexDebug'. [Android] Execution failed for task ':app:mergeLibDexDebug'. RNGH conflicts with MMKV when fabric enabled Jan 26, 2023
cortinico added a commit to cortinico/react-native that referenced this issue Jan 27, 2023
Summary:
Fixes software-mansion/react-native-gesture-handler#2382

I've just realized that the default value fo `jsRootDir` is not entirely correct.
That's the root of the folder where the codegen should run.

For apps, it should be defaulted to `root` (i.e. ../../)
For libraries, it should be defaulted to `../` (currently is root).

This causes a problem where libraries without either a `codegenConfig` or a `react{ jsRootDir = ... }`
specified in the build.gradle will be invoking the codegen and generating duplicated symbols.

Changelog:
[Android] [Fixed] - RNGP - Properly set the `jsRootDir` default value

Differential Revision: D42806411

fbshipit-source-id: 44371edec593aba5a5115d05e6f8d2e86ec6dc11
@cortinico
Copy link

Just a heads up that this caused by an underlying bug in the codegen. It's addressed here: facebook/react-native#35992

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Jan 30, 2023
Summary:
Pull Request resolved: #35992

Fixes software-mansion/react-native-gesture-handler#2382

I've just realized that the default value fo `jsRootDir` is not entirely correct.
That's the root of the folder where the codegen should run.

For apps, it should be defaulted to `root` (i.e. ../../)
For libraries, it should be defaulted to `../` (currently is root).

This causes a problem where libraries without either a `codegenConfig` or a `react{ jsRootDir = ... }`
specified in the build.gradle will be invoking the codegen and generating duplicated symbols.

Changelog:
[Android] [Fixed] - RNGP - Properly set the `jsRootDir` default value

Reviewed By: cipolleschi

Differential Revision: D42806411

fbshipit-source-id: ffe45f9684a22494cc2e4d0a19de9077cb341365
kelset pushed a commit to facebook/react-native that referenced this issue Jan 30, 2023
Summary:
Pull Request resolved: #35992

Fixes software-mansion/react-native-gesture-handler#2382

I've just realized that the default value fo `jsRootDir` is not entirely correct.
That's the root of the folder where the codegen should run.

For apps, it should be defaulted to `root` (i.e. ../../)
For libraries, it should be defaulted to `../` (currently is root).

This causes a problem where libraries without either a `codegenConfig` or a `react{ jsRootDir = ... }`
specified in the build.gradle will be invoking the codegen and generating duplicated symbols.

Changelog:
[Android] [Fixed] - RNGP - Properly set the `jsRootDir` default value

Reviewed By: cipolleschi

Differential Revision: D42806411

fbshipit-source-id: ffe45f9684a22494cc2e4d0a19de9077cb341365
@devoren
Copy link
Author

devoren commented Feb 1, 2023

After upgrading RN to v0.71.2 issue was resolved

@devoren devoren closed this as completed Feb 1, 2023
@cortinico
Copy link

Awesome :)

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this issue May 22, 2023
Summary:
Pull Request resolved: facebook#35992

Fixes software-mansion/react-native-gesture-handler#2382

I've just realized that the default value fo `jsRootDir` is not entirely correct.
That's the root of the folder where the codegen should run.

For apps, it should be defaulted to `root` (i.e. ../../)
For libraries, it should be defaulted to `../` (currently is root).

This causes a problem where libraries without either a `codegenConfig` or a `react{ jsRootDir = ... }`
specified in the build.gradle will be invoking the codegen and generating duplicated symbols.

Changelog:
[Android] [Fixed] - RNGP - Properly set the `jsRootDir` default value

Reviewed By: cipolleschi

Differential Revision: D42806411

fbshipit-source-id: ffe45f9684a22494cc2e4d0a19de9077cb341365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing info Missing repro Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants