From afc5d39768d4ce1e5d35da0ad8c44f0ae62e492f Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 2 Feb 2023 03:35:55 -0800 Subject: [PATCH] RNGP - Bump AGP to 7.4.1 Summary: This change bumps AGP to 7.4.1 so we can remove a lot of the unnecessary changes we had to do to support AGP 7.3.x I've also removed the explicit version in the template as now the AGP version is provided by RNGP. That means that the user will get the correct version they need. This also bumps the default CMake version in user space to 3.22 which resolves a lot of warning when users are building with the New Architecture enabled. Changelog: [Android] [Changed] - Bump AGP to 7.4.1 Differential Revision: D42960353 fbshipit-source-id: ef6e3764c842538b762ae57e85d645f90bf8c89a --- build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../kotlin/com/facebook/react/ReactPlugin.kt | 19 ------------------- .../com/facebook/react/TaskConfiguration.kt | 4 +--- template/android/build.gradle | 2 +- 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bcdbd6c874f2a8..dde63fc00734fc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,7 +33,7 @@ buildscript { gradlePluginPortal() } dependencies { - classpath("com.android.tools.build:gradle:7.3.1") + classpath("com.android.tools.build:gradle:7.4.1") classpath("de.undercouch:gradle-download-task:5.0.1") } } diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts index 5ea92ee71b41c8..8a54bdaaa9e6a2 100644 --- a/packages/react-native-gradle-plugin/build.gradle.kts +++ b/packages/react-native-gradle-plugin/build.gradle.kts @@ -33,7 +33,7 @@ group = "com.facebook.react" dependencies { implementation(gradleApi()) - implementation("com.android.tools.build:gradle:7.3.1") + implementation("com.android.tools.build:gradle:7.4.1") implementation("com.google.code.gson:gson:2.8.9") implementation("com.google.guava:guava:31.0.1-jre") implementation("com.squareup:javapoet:1.13.0") diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index 48fff59c790a38..8aa1c5bbdb0d9a 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -8,7 +8,6 @@ package com.facebook.react import com.android.build.api.variant.AndroidComponentsExtension -import com.android.build.gradle.AppExtension import com.android.build.gradle.internal.tasks.factory.dependsOn import com.facebook.react.tasks.BuildCodegenCLITask import com.facebook.react.tasks.GenerateCodegenArtifactsTask @@ -55,24 +54,6 @@ class ReactPlugin : Plugin { project.configureReactTasks(variant = variant, config = extension) } } - - // This is a legacy AGP api. Needed as AGP 7.3 is not consuming generated resources correctly. - // Can be removed as we bump to AGP 7.4 stable. - // This registers the $buildDir/generated/res/react/ 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 { 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) } diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt index 30bad252fd823b..24ba33b297c692 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt @@ -72,9 +72,7 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio it.hermesFlags.set(config.hermesFlags) it.reactNativeDir.set(config.reactNativeDir) } - // Currently broken inside AGP 7.3 We need to wait for a release of AGP 7.4 in order to use - // the addGeneratedSourceDirectory API. - // variant.sources.res?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::resourcesDir) + variant.sources.res?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::resourcesDir) variant.sources.assets?.addGeneratedSourceDirectory(bundleTask, BundleHermesCTask::jsBundleDir) } } diff --git a/template/android/build.gradle b/template/android/build.gradle index 67d887b03078b6..34ea71819406f6 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -15,7 +15,7 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:7.3.1") + classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") } }