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

[React Native 0.76.2] Android bundle build failing while using new architecture. #2273

Open
2 tasks done
einjunge99 opened this issue Dec 10, 2024 · 4 comments
Open
2 tasks done
Labels
awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks.

Comments

@einjunge99
Copy link

Describe the bug

Created a new project and followed the manual setup guide. App works fine on emulator/physical device, but when I try to build it, it throws the following error:

Execution failed for task ':app:configureCMakeRelWithDebInfo[arm64-v8a]'.

Upon further inspection, as the logs attached below states, no /Users/isaacmaldonado/Documents/Projects/Template/node_modules/@bugsnag/react-native/android/build/generated/source/codegen/jni/ were generated.

Steps to reproduce

  1. Create new react native project with npx @react-native-community/cli@latest init <APP_NAME> --version 0.76.2
  2. Follow react native manual setup guide
  3. cd android folder and run ./gradlew bundleRelease
  4. See error

Environment

  • MacOS (M1)
  • Bugsnag version: 8.1.3
  • NodeJS: 20.15.1
  • Java: zulu-17.46.19

Example Repo

  • Create a minimal repository that can reproduce the issue
  • Link to it here: https://github.com/einjunge99/template (Remember to replace YOUR_BUGSNAG_API_KEY with your own Bugsnag API key on android/app/src/main/AndroidManifest.xml)
Error messages:
> Task :app:configureCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at /Users/isaacmaldonado/Documents/Projects/Template/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
C/C++:   add_subdirectory given source
C/C++:   "/Users/isaacmaldonado/Documents/Projects/Template/node_modules/@bugsnag/react-native/android/build/generated/source/codegen/jni/"
C/C++:   which is not an existing directory.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/isaacmaldonado/Documents/Projects/Template/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++:   CMakeLists.txt:31 (include)
C/C++: CMake Error at /Users/isaacmaldonado/Documents/Projects/Template/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
C/C++:   Cannot specify link libraries for target
C/C++:   "react_codegen_BugsnagReactNativeSpec" which is not built by this project.
C/C++: Call Stack (most recent call first):
C/C++:   CMakeLists.txt:31 (include)
@clr182
Copy link

clr182 commented Jan 7, 2025

Hi @einjunge99

Thanks for reaching out.

I downloaded the reproduction you shared and did see the same issues after running ./gradle bundleRelease.
I believe this issue may be due to the version of React Native you are running (0.76) which is not able to run codegen for the bundleRelease task.
With the new arch enabled, could you please try running the ./gradlew generateCodegenArtifactsFromSchema task before trying your build again, and let us know whether this is successful?

@clr182 clr182 added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Jan 7, 2025
@cortinico
Copy link

Hey,
Nicola here from the React Native team.

@einjunge99 thanks for opening this issue.
It seems like the problem is, as @clr182, related to codegen for bugsnag being invoked "too late".

This is confirmed by:

$ ./gradlew :app:buildCMakeDebug --dry-run
:app:bugsnagInstallJniLibsTask SKIPPED
:app:generateAutolinkingNewArchitectureFiles SKIPPED
:app:generateAutolinkingPackageList SKIPPED
:app:generateCodegenSchemaFromJavaScript SKIPPED
:app:generateCodegenArtifactsFromSchema SKIPPED
:app:preBuild SKIPPED
:app:preDebugBuild SKIPPED
:app:configureCMakeDebug[arm64-v8a] SKIPPED
:app:buildCMakeDebug[arm64-v8a] SKIPPED
:app:buildCMakeDebug SKIPPED

Essentially once the app starts the C++ compilation, the codegen for bugsnag hasn't executed and it will let the compilation fail because of a missing file.

I'm trying to understand why this is surfacing now. @einjunge99 is the same issue also happening on 0.75? @clr182 does this ring any bell? Is bugsnag doing something with tasks dependencies?

As a workaround you can either:

  • Invoke ./gradlew generateCodegenArtifactsFromSchema before building as @clr182 suggested
  • Add the following line at the end of your android/app/build.gradle:
preBuild.dependsOn(":bugsnag_react-native:preBuild")

I'd love to fix this inside React Native though as other libraries might be affected by this as well (however this is the first time this issue is surfaced).

@yousif-bugsnag
Copy link
Contributor

yousif-bugsnag commented Jan 13, 2025

Hi @einjunge99 and @cortinico,

Thanks for reporting this.

Turns out I was wrong about this - this issue isn't related to the React Native 0.76 release and is actually to do with the inclusion of bugsnag-android-gradle-plugin (which does do something with task dependencies).

The workarounds listed above will work, but for React Native projects we'd actually recommend removing bugsnag-android-gradle-plugin and using the BugSnag CLI, which replaces the Gradle plugin and handles symbol and mapping file uploads.

If you use our React Native CLI package (npx @bugsnag/react-native-cli init) to install BugSnag, then it will have installed the CLI tool, but it looks like the manual setup guide in our docs is a little out of date and still references bugsnag-android-gradle-plugin. We'll look to get this updated ASAP, but in the meantime you can follow the steps here to set up the CLI tool manually.

@cortinico
Copy link

That's great thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks.
Projects
None yet
Development

No branches or pull requests

4 participants