Skip to content

Commit 60b9d8c

Browse files
cortinicofacebook-github-bot
authored andcommitted
Fix for resources not correctly bundlded on release appbundles (#35872)
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
1 parent 470f79b commit 60b9d8c

File tree

1 file changed

+10
-3
lines changed
  • packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react

1 file changed

+10
-3
lines changed

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,16 @@ class ReactPlugin : Plugin<Project> {
6161
// This registers the $buildDir/generated/res/react/<variant> folder as a
6262
// res folder to be consumed with the old AGP Apis which are not broken.
6363
project.extensions.getByType(AppExtension::class.java).apply {
64-
this.applicationVariants.all {
65-
it.registerGeneratedResFolders(
66-
project.layout.buildDirectory.files("generated/res/react/${it.name}"))
64+
this.applicationVariants.all { variant ->
65+
val isDebuggableVariant =
66+
extension.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) }
67+
val targetName = variant.name.replaceFirstChar { it.uppercase() }
68+
val bundleTaskName = "createBundle${targetName}JsAndAssets"
69+
if (!isDebuggableVariant) {
70+
variant.registerGeneratedResFolders(
71+
project.layout.buildDirectory.files("generated/res/react/${variant.name}"))
72+
variant.mergeResourcesProvider.get().dependsOn(bundleTaskName)
73+
}
6774
}
6875
}
6976
configureCodegen(project, extension, isLibrary = false)

0 commit comments

Comments
 (0)