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 release bundle is not generated in the correct location on RN 0.71.0-rc.0 #35398

Closed
louiszawadzki opened this issue Nov 18, 2022 · 8 comments
Labels
Needs: Attention Issues where the author has responded to feedback.

Comments

@louiszawadzki
Copy link
Contributor

louiszawadzki commented Nov 18, 2022

Description

When building for release on Android (yarn android --variant=release), the bundle file is located at android/app/build/ASSETS/createBundleReleaseJsAndAssets/index.android.bundle, which is a change from the previous location of android/app/build/generated/assets/react/Release/index.android.bundle.
The android/app/build/generated does not contain an assets directory anymore.

By looking at the gradle-plugin code, I'm assuming it's not supposed to have changed.

Version

0.71.0-rc.0

Output of npx react-native info

System:
    OS: macOS 12.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.37 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.11.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - ~/.npm-global/bin/yarn
    npm: 8.19.2 - /opt/homebrew/bin/npm
    Watchman: 2022.10.24.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.0-rc.0 => 0.71.0-rc.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  • Create a new app using the command: npx react-native init <YourAppName> --version 0.71.0-rc.0
  • Manually download the maven-local.zip archive (you can also find the link in this release).
  • Unzip the maven-local.zip on a folder on your disk.
  • Add the REACT_NATIVE_MAVEN_LOCAL_REPO=<path_to_the_maven-local_unzipped_folder> setting to the android/gradle.properties file
  • Build with yarn android --variant=release

Snack, code example, screenshot, or link to a repository

Screenshot of the android folder directory after a build:

image

@louiszawadzki
Copy link
Contributor Author

After a quick investigation, deleting this line makes the bundle to be generated in the right location again:

variant.sources.assets?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::jsBundleDir)

@cortinico
Copy link
Contributor

When building for release on Android (yarn android --variant=release), the bundle file is located at android/app/build/ASSETS/createBundleReleaseJsAndAssets/index.android.bundle, which is a change from the previous location of android/app/build/generated/assets/react/Release/index.android.bundle.
The android/app/build/generated does not contain an assets directory anymore.

I don't understand what's the bug here.
The index.android.bundle is properly located in the final APK (as the app is running).

Images are missing, which is another bug we're looking into #35439.

But what should be fixed here?

@louiszawadzki
Copy link
Contributor Author

I work on the Datadog SDK, which provide an error tracking system. We use the bundle for adding more context to errors in Datadog, in addition to the sourcemaps.
We also provide users with a script that will locate that bundle and upload it. Currently it looks for android/app/build/generated/assets/react/{variant}/index.android.bundle.

If the location changes it's not so much of an issue for us, I wanted to raise this to get confirmation that this is indeed going to change before making the change on our side, and in case there was some bug hidden behind it.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 23, 2022
@louiszawadzki
Copy link
Contributor Author

I'll close this issue, as it seems there is no hidden bug behind it :)

@cortinico
Copy link
Contributor

I'll close this issue, as it seems there is no hidden bug behind it :)

Nope the change was intended. We now use the Artifacts API of AGP so we don't have to "hardcode" paths around anymore. As AGP changes paths, we won't be affected by future breakages.

@mym0404
Copy link
Contributor

mym0404 commented Jan 17, 2023

I am upload js bundle to Sentry manually.
It seems to generated js bundle path is changed in 0.71.
Well, the release app is running well.
So I just changed generated bundle path to app/build/ASSETS/createBundleReleaseJsAndAssets/index.android.bundle

I have no idea this is a correct fix.

@louiszawadzki
Copy link
Contributor Author

Hi @mym0404,

This is indeed the correct fix from our conversation ahead.
When you'll update the Android Gradle Plugin to 7.4.0 or above (probably with RN 0.72) the new path will be app/build/generated/assets/createBundleReleaseJsAndAssets/index.android.bundle.

@mym0404
Copy link
Contributor

mym0404 commented Jan 17, 2023

I will remember it. Thank you for response 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback.
Projects
None yet
Development

No branches or pull requests

3 participants