Skip to content

[Android] Can not test the example app in release mode #774

Description

@ISnowFoxI

Description

I have built a small library using nitro-modules but when I run yarn android --mode release command, the app doesn't build. It fails with the following error.

Type com.facebook.fbreact.specs.NativeAccessibilityInfoSpec is defined multiple times:

* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> 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.fbreact.specs.NativeAccessibilityInfoSpec is defined multiple times: /Users/user/Desktop/rn-sima-app-to-app/android/build/.transforms/fc48dddb342cbad626efc1aa92bb0c2f/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/facebook/fbreact/specs/NativeAccessibilityInfoSpec.dex, /Users/user/Desktop/rn-sima-app-to-app/example/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes.dex

Packages

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

Selected options

Package name: rn-sima-app-to-app
Library type: Nitro modules

Link to repro

https://github.com/ISnowFoxI/rn-sima-app-to-app

Environment

System:
OS: macOS 15.3
CPU: (8) arm64 Apple M1 Pro
Memory: 273.69 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.11.0
path: ~/.nvm/versions/node/v20.11.0/bin/node
Yarn:
version: 3.6.1
path: ~/.nvm/versions/node/v20.11.0/bin/yarn
npm:
version: 10.2.4
path: ~/.nvm/versions/node/v20.11.0/bin/npm
Watchman:
version: 2024.12.02.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK:
API Levels:
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
Build Tools:
- 30.0.2
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
- 35.0.0
System Images:
- android-34 | Google APIs ARM 64 v8a
- android-34 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.2 AI-242.23726.103.2422.12816248
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.12
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.77.0
wanted: 0.77.0
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false

Activity

  1. changed the title [-][Android] Cannot test the example app in release moda[/-] [+][Android] Cannot test the example app in release mode[/+] on Feb 20, 2025
  2. changed the title [-][Android] Cannot test the example app in release mode[/-] [+][Android] Can not test the example app in release mode[/+] on Feb 20, 2025
  3. ISnowFoxI commented on Feb 21, 2025

    @ISnowFoxI
    Author

    Commenting out the below code fixes it. The code is located in the build.gradle file of the library. I am curious whether this is important or not, if the example app has this already, why is it needed in the package file?

    if (isNewArchitectureEnabled()) {
      apply plugin: "com.facebook.react"
    }
    
  4. ISnowFoxI commented on Feb 24, 2025

    @ISnowFoxI
    Author

    I am going to rebuild the library so, I will delete the reproduction repo.

  5. reopened this on Feb 24, 2025
  6. atlj commented on Feb 24, 2025

    @atlj
    Collaborator

    Hey @ISnowFoxI I was able to reproduce it locally so let's keep this issue open until we fix it. And thank you so much for the suggestion. Will take a look

  7. ISnowFoxI commented on Feb 24, 2025

    @ISnowFoxI
    Author

    Hey @atlj, sure thing. But I've already deleted the repo, Would you mind creating a new reproduction repo?

  8. atlj commented on Feb 24, 2025

    @atlj
    Collaborator

    Would you mind creating a new reproduction repo?

    No worries, since I'm able to reproduce it, we don't need a repro again.

  9. chanphiromsok commented on Sep 26, 2025

    @chanphiromsok

    Commenting out the below code fixes it. The code is located in the build.gradle file of the library. I am curious whether this is important or not, if the example app has this already, why is it needed in the package file?

    if (isNewArchitectureEnabled()) {
      apply plugin: "com.facebook.react"
    }
    

    comment this in android/build.gradle is resolve the issue

  10. shawnthye-guru commented on Jun 23, 2026

    @shawnthye-guru

    Hit the same problem, what should be the recommendation? remove the react plugin block?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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