Skip to content

Commit

Permalink
Fix for resources not correctly bundlded on release appbundles (#35872)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #35872

When downgrading from AGP 7.4 to 7.3 we were forced to resort to older APIs
to bundle resources. It seems like we haven't properly wired the task to make sure
resources generated by Metro are correctly accounted before the generation of
release app bundles/apks.

This fixes it. This fix can also be removed once we are on AGP 7.4
Fixes #35865

Changelog:
[Android] [Fixed] - Fix for resources not correctly bundlded on release appbundles

Reviewed By: cipolleschi

Differential Revision: D42573450

fbshipit-source-id: a810924315f72e02e4c988ae86112bf0a06a9ce5
  • Loading branch information
cortinico authored and facebook-github-bot committed Jan 18, 2023
1 parent 470f79b commit 60b9d8c
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ class ReactPlugin : Plugin<Project> {
// This registers the $buildDir/generated/res/react/<variant> folder as a
// res folder to be consumed with the old AGP Apis which are not broken.
project.extensions.getByType(AppExtension::class.java).apply {
this.applicationVariants.all {
it.registerGeneratedResFolders(
project.layout.buildDirectory.files("generated/res/react/${it.name}"))
this.applicationVariants.all { variant ->
val isDebuggableVariant =
extension.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) }
val targetName = variant.name.replaceFirstChar { it.uppercase() }
val bundleTaskName = "createBundle${targetName}JsAndAssets"
if (!isDebuggableVariant) {
variant.registerGeneratedResFolders(
project.layout.buildDirectory.files("generated/res/react/${variant.name}"))
variant.mergeResourcesProvider.get().dependsOn(bundleTaskName)
}
}
}
configureCodegen(project, extension, isLibrary = false)
Expand Down

0 comments on commit 60b9d8c

Please sign in to comment.