Skip to content

Nitro module library crash on android example buildΒ #896

@jaworek

Description

@jaworek

Description

After generating new library using npx create-react-native-library@latest awesome-librar and selecting "Nitro module" option, installing packages with yarn, and running yarn example android, I encountered an error.
It looks like unused react-native-safe-area-context dependency from example app is getting registered multiple times.

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.RNCSafeAreaProviderManagerDelegate is defined multiple times: /Users/john/Desktop/awesome-library/android/build/.transforms/9286b72b4f9552335ae00fc4394f0219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.dex, /Users/john/Desktop/awesome-library/example/node_modules/react-native-safe-area-context/android/build/.transforms/def7637fb683de95fb0b5f690e7a6ad7/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.dex

I tried to find the duplicate, but the only place where it's declared is in example/package.json:

yarn why react-native-safe-area-context
└─ awesome-library-example@workspace:
└─ react-native-safe-area-context@npm:5.6.1 [fb98e] (via npm:^5.5.2 [fb98e])

Creating library with Turbo module does not result in the same error, even though react-native-safe-area-context is also present there.

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

Image

Link to repro

https://github.com/jaworek/awesome-library

Environment

System:
OS: macOS 26.0
CPU: (11) arm64 Apple M3 Pro
Memory: 393.58 MB / 36.00 GB
Shell:
version: 5.3.3
path: /nix/store/j26b6rcrvvpvqqcq5gmzxxipjb8ycy09-bash-interactive-5.3p3/bin/bash
Binaries:
Node:
version: 20.19.4
path: /opt/homebrew/bin/node
Yarn:
version: 3.6.1
path: /nix/store/38vyy0sbiqaq3r5liws3yfhxlhgcwsyz-yarn-berry-3.8.7/bin/yarn
npm:
version: 10.8.2
path: /opt/homebrew/bin/npm
Watchman:
version: 2025.09.15.00
path: /etc/profiles/per-user/john/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /etc/profiles/per-user/john/bin/pod
SDKs:
iOS SDK: Not Found
Android SDK:
API Levels:
- "33"
- "35"
- "36"
Build Tools:
- 33.0.1
- 34.0.0
- 35.0.0
- 36.0.0
System Images:
- android-33 | Android TV ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.26094.121.2513.14007798
Xcode:
version: /undefined
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.12
path: /etc/profiles/per-user/john/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.81.1
wanted: 0.81.1
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions