Skip to content

Static images are not rendered on Android for 0.71.0-rc.0 #35439

Description

@louiszawadzki

Description

Static images (like the logo in the header of a newly generated application) are not rendered on Android in 0.71.0-rc.0.

Cause of the bug

I've done a bit of investigation, here is what I found:

In the react-native-gradle-plugin, we use variant.sources.res?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::resourcesDir) which changes the resourcesDir of the bundleTask to RES/createBundleReleaseJsAndAssets: https://android.googlesource.com/platform/tools/base/+blame/186d0522f7fc1f02e33c197f40a5b7ce8834f110/build-system/gradle-core/src/main/java/com/android/build/api/variant/impl/SourceDirectoriesImpl.kt#54

There has been a fix applied in android-gradle-plugin version 7.4.0-beta05, so the new path is then generates/res/createBundleReleaseJsAndAssets, and with this version I can see the image 🥳.

So one solution is to wait for android-gradle-plugin version 7.4.0 to be released.

However, resources won't be in "generated/res/react/Release" which is the path specified in the react-native-gradle-plugin, I think this can be misleading.
This path should be changed as well, or the resources should be copied over to that directory as well, as what used to be done with react.gradle.

This is exactly the same cause as #35398.

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: 7.11 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

With "com.android.tools.build:gradle:7.3.1":
image

With "com.android.tools.build:gradle:7.4.0-beta05":
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions