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

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

Closed
louiszawadzki opened this issue Nov 23, 2022 · 3 comments
Closed

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

louiszawadzki opened this issue Nov 23, 2022 · 3 comments

Comments

@louiszawadzki
Copy link
Contributor

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

@cortinico
Copy link
Contributor

Thansk for sharing this @louiszawadzki It's under my radar. I'll try to reproduce and get back to you

@cortinico
Copy link
Contributor

I was able to reproduce. That's a bug on AGP 7.3
https://issuetracker.google.com/issues/237421684
The issue is fixed on AGP 7.4.0-beta05. I've tried to bump locally and the images are bundled correctly.

So either we bump AGP to 7.4.0-beta05 or we try to ask for a backport of that fix on AGP 7.3

cortinico added a commit to cortinico/react-native that referenced this issue Nov 24, 2022
Summary:
Fixes facebook#35439

There is a bug in AGP 7.3.x which is causing assets to don't be copied properly inside the
final artifact: issuetracker.google.com/issues/237421684
As AGP 7.4.x is really close to release (is in Beta5, should be released stable in the next weeks)
we should be fine by bumping to beta5.

This also requires a bump of RNGP

Changelog:
[Android] [Changed] - Bump AGP to 7.4.x

allow-large-files

Differential Revision: D41519549

fbshipit-source-id: a64e3ef73bb0df691cf9d2cde8f340aac75ac009
cortinico added a commit that referenced this issue Nov 29, 2022
Summary:
Pull Request resolved: #35456

Fixes #35439

There is a bug in AGP 7.3.x which is causing assets to don't be copied properly inside the
final artifact: issuetracker.google.com/issues/237421684
As AGP 7.4.x is really close to release (is in Beta5, should be released stable in the next weeks)
we should be fine by bumping to beta5.

This also requires a bump of RNGP

Changelog:
[Android] [Changed] - Bump AGP to 7.4.x

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D41519549

fbshipit-source-id: 60d568a3e49798a23f1d7bf4839ab58bd5549aba
@kelset
Copy link
Contributor

kelset commented Dec 1, 2022

@louiszawadzki can you try out RC3? It has the bump to AGP 7.4 beta so the problem should be addressed

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this issue May 22, 2023
Summary:
Pull Request resolved: facebook#35456

Fixes facebook#35439

There is a bug in AGP 7.3.x which is causing assets to don't be copied properly inside the
final artifact: issuetracker.google.com/issues/237421684
As AGP 7.4.x is really close to release (is in Beta5, should be released stable in the next weeks)
we should be fine by bumping to beta5.

This also requires a bump of RNGP

Changelog:
[Android] [Changed] - Bump AGP to 7.4.x

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D41519549

fbshipit-source-id: 60d568a3e49798a23f1d7bf4839ab58bd5549aba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants