Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for resources not correctly bundlded on release appbundles (faceb…
Browse files Browse the repository at this point in the history
…ook#35872)

Summary:
Pull Request resolved: facebook#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 facebook#35865

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

Reviewed By: cipolleschi

Differential Revision: D42573450

fbshipit-source-id: a810924315f72e02e4c988ae86112bf0a06a9ce5
cortinico authored and OlimpiaZurek committed May 22, 2023
1 parent c6a1fd0 commit 8208e07
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8208e07

Please sign in to comment.