mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Bump AGP to 8.10.x (#51854)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51854 AGP 8.10.x comes with a source breaking change: https://issuetracker.google.com/issues/416890061 This shoudl fix it and unblock us for the 0.81 release. Changelog: [Android] [Changed] - Bump AGP to 8.10.x Reviewed By: huntie Differential Revision: D76053989 fbshipit-source-id: b0fe19544c79d65002127176f2722cdfd85f0a3c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
17466a07a5
commit
4f9090bc57
@@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
agp = "8.9.2"
|
||||
agp = "8.10.1"
|
||||
gson = "2.8.9"
|
||||
guava = "31.0.1-jre"
|
||||
javapoet = "1.13.0"
|
||||
|
||||
+16
-6
@@ -7,7 +7,8 @@
|
||||
|
||||
package com.facebook.react
|
||||
|
||||
import com.android.build.api.variant.AndroidComponentsExtension
|
||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.android.build.api.variant.LibraryAndroidComponentsExtension
|
||||
import com.android.build.gradle.internal.tasks.factory.dependsOn
|
||||
import com.facebook.react.internal.PrivateReactExtension
|
||||
import com.facebook.react.tasks.GenerateAutolinkingNewArchitecturesFileTask
|
||||
@@ -75,7 +76,7 @@ class ReactPlugin : Plugin<Project> {
|
||||
configureBackwardCompatibilityReactMap(project)
|
||||
configureJavaToolChains(project)
|
||||
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).apply {
|
||||
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).apply {
|
||||
onVariants(selector().all()) { variant ->
|
||||
project.configureReactTasks(variant = variant, config = extension)
|
||||
}
|
||||
@@ -114,7 +115,8 @@ class ReactPlugin : Plugin<Project> {
|
||||
|
||||
/** This function configures Android resources - in this case just the bundle */
|
||||
private fun configureResources(project: Project, reactExtension: ReactExtension) {
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).finalizeDsl {
|
||||
ext ->
|
||||
val bundleFileExtension = reactExtension.bundleAssetName.get().substringAfterLast('.', "")
|
||||
if (!reactExtension.enableBundleCompression.get() && bundleFileExtension.isNotBlank()) {
|
||||
ext.androidResources.noCompress.add(bundleFileExtension)
|
||||
@@ -215,8 +217,16 @@ class ReactPlugin : Plugin<Project> {
|
||||
// This equivalent to this DSL:
|
||||
//
|
||||
// android { sourceSets { main { java { srcDirs += "$generatedSrcDir/java" } } } }
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
ext.sourceSets.getByName("main").java.srcDir(generatedSrcDir.get().dir("java").asFile)
|
||||
if (isLibrary) {
|
||||
project.extensions.getByType(LibraryAndroidComponentsExtension::class.java).finalizeDsl { ext
|
||||
->
|
||||
ext.sourceSets.getByName("main").java.srcDir(generatedSrcDir.get().dir("java").asFile)
|
||||
}
|
||||
} else {
|
||||
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).finalizeDsl {
|
||||
ext ->
|
||||
ext.sourceSets.getByName("main").java.srcDir(generatedSrcDir.get().dir("java").asFile)
|
||||
}
|
||||
}
|
||||
|
||||
// `preBuild` is one of the base tasks automatically registered by AGP.
|
||||
@@ -282,7 +292,7 @@ class ReactPlugin : Plugin<Project> {
|
||||
|
||||
// We tell Android Gradle Plugin that inside /build/generated/autolinking/src/main/java there
|
||||
// are sources to be compiled as well.
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).apply {
|
||||
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).apply {
|
||||
onVariants(selector().all()) { variant ->
|
||||
variant.sources.java?.addStaticSourceDirectory(
|
||||
generatedAutolinkingJavaDir.get().asFile.absolutePath)
|
||||
|
||||
+38
-30
@@ -7,7 +7,8 @@
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import com.android.build.api.variant.AndroidComponentsExtension
|
||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.android.build.api.variant.LibraryAndroidComponentsExtension
|
||||
import com.android.build.gradle.LibraryExtension
|
||||
import com.facebook.react.ReactExtension
|
||||
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
|
||||
@@ -28,15 +29,17 @@ internal object AgpConfiguratorUtils {
|
||||
fun configureBuildConfigFieldsForApp(project: Project, extension: ReactExtension) {
|
||||
val action =
|
||||
Action<AppliedPlugin> {
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
ext.buildFeatures.buildConfig = true
|
||||
ext.defaultConfig.buildConfigField(
|
||||
"boolean",
|
||||
"IS_NEW_ARCHITECTURE_ENABLED",
|
||||
project.isNewArchEnabled(extension).toString())
|
||||
ext.defaultConfig.buildConfigField(
|
||||
"boolean", "IS_HERMES_ENABLED", project.isHermesEnabled.toString())
|
||||
}
|
||||
project.extensions
|
||||
.getByType(ApplicationAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext ->
|
||||
ext.buildFeatures.buildConfig = true
|
||||
ext.defaultConfig.buildConfigField(
|
||||
"boolean",
|
||||
"IS_NEW_ARCHITECTURE_ENABLED",
|
||||
project.isNewArchEnabled(extension).toString())
|
||||
ext.defaultConfig.buildConfigField(
|
||||
"boolean", "IS_HERMES_ENABLED", project.isHermesEnabled.toString())
|
||||
}
|
||||
}
|
||||
project.pluginManager.withPlugin("com.android.application", action)
|
||||
project.pluginManager.withPlugin("com.android.library", action)
|
||||
@@ -45,9 +48,9 @@ internal object AgpConfiguratorUtils {
|
||||
fun configureBuildConfigFieldsForLibraries(appProject: Project) {
|
||||
appProject.rootProject.allprojects { subproject ->
|
||||
subproject.pluginManager.withPlugin("com.android.library") {
|
||||
subproject.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
ext.buildFeatures.buildConfig = true
|
||||
}
|
||||
subproject.extensions
|
||||
.getByType(LibraryAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext -> ext.buildFeatures.buildConfig = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,10 +61,13 @@ internal object AgpConfiguratorUtils {
|
||||
|
||||
val action =
|
||||
Action<AppliedPlugin> {
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
ext.defaultConfig.resValue("string", "react_native_dev_server_ip", getHostIpAddress())
|
||||
ext.defaultConfig.resValue("integer", "react_native_dev_server_port", devServerPort)
|
||||
}
|
||||
project.extensions
|
||||
.getByType(ApplicationAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext ->
|
||||
ext.defaultConfig.resValue(
|
||||
"string", "react_native_dev_server_ip", getHostIpAddress())
|
||||
ext.defaultConfig.resValue("integer", "react_native_dev_server_port", devServerPort)
|
||||
}
|
||||
}
|
||||
|
||||
project.pluginManager.withPlugin("com.android.application", action)
|
||||
@@ -71,20 +77,22 @@ internal object AgpConfiguratorUtils {
|
||||
fun configureNamespaceForLibraries(appProject: Project) {
|
||||
appProject.rootProject.allprojects { subproject ->
|
||||
subproject.pluginManager.withPlugin("com.android.library") {
|
||||
subproject.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
if (ext.namespace == null) {
|
||||
val android = subproject.extensions.getByType(LibraryExtension::class.java)
|
||||
val manifestFile = android.sourceSets.getByName("main").manifest.srcFile
|
||||
subproject.extensions
|
||||
.getByType(LibraryAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext ->
|
||||
if (ext.namespace == null) {
|
||||
val android = subproject.extensions.getByType(LibraryExtension::class.java)
|
||||
val manifestFile = android.sourceSets.getByName("main").manifest.srcFile
|
||||
|
||||
manifestFile
|
||||
.takeIf { it.exists() }
|
||||
?.let { file ->
|
||||
getPackageNameFromManifest(file)?.let { packageName ->
|
||||
ext.namespace = packageName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
manifestFile
|
||||
.takeIf { it.exists() }
|
||||
?.let { file ->
|
||||
getPackageNameFromManifest(file)?.let { packageName ->
|
||||
ext.namespace = packageName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-9
@@ -7,7 +7,8 @@
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import com.android.build.api.variant.AndroidComponentsExtension
|
||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.android.build.api.variant.LibraryAndroidComponentsExtension
|
||||
import com.facebook.react.utils.PropertyUtils.INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.JavaVersion
|
||||
@@ -31,16 +32,27 @@ internal object JdkConfiguratorUtils {
|
||||
if (project.hasProperty(INTERNAL_DISABLE_JAVA_VERSION_ALIGNMENT)) {
|
||||
return@allprojects
|
||||
}
|
||||
val action =
|
||||
|
||||
val applicationAction =
|
||||
Action<AppliedPlugin> {
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext
|
||||
->
|
||||
ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
|
||||
ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
project.extensions
|
||||
.getByType(ApplicationAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext ->
|
||||
ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
|
||||
ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
project.pluginManager.withPlugin("com.android.application", action)
|
||||
project.pluginManager.withPlugin("com.android.library", action)
|
||||
val libraryAction =
|
||||
Action<AppliedPlugin> {
|
||||
project.extensions
|
||||
.getByType(LibraryAndroidComponentsExtension::class.java)
|
||||
.finalizeDsl { ext ->
|
||||
ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_17
|
||||
ext.compileOptions.targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
project.pluginManager.withPlugin("com.android.application", applicationAction)
|
||||
project.pluginManager.withPlugin("com.android.library", libraryAction)
|
||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.android") {
|
||||
project.kotlinExtension.jvmToolchain(17)
|
||||
}
|
||||
|
||||
+3
-2
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.facebook.react.utils
|
||||
|
||||
import com.android.build.api.variant.AndroidComponentsExtension
|
||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.android.build.api.variant.Variant
|
||||
import com.facebook.react.ReactExtension
|
||||
import com.facebook.react.utils.ProjectUtils.getReactNativeArchitectures
|
||||
@@ -19,7 +19,8 @@ internal object NdkConfiguratorUtils {
|
||||
@Suppress("UnstableApiUsage")
|
||||
fun configureReactNativeNdk(project: Project, extension: ReactExtension) {
|
||||
project.pluginManager.withPlugin("com.android.application") {
|
||||
project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext ->
|
||||
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).finalizeDsl {
|
||||
ext ->
|
||||
if (!project.isNewArchEnabled(extension)) {
|
||||
// For Old Arch, we don't need to setup the NDK
|
||||
return@finalizeDsl
|
||||
|
||||
@@ -6,7 +6,7 @@ compileSdk = "35"
|
||||
buildTools = "35.0.0"
|
||||
ndkVersion = "27.1.12297006"
|
||||
# Dependencies versions
|
||||
agp = "8.9.2"
|
||||
agp = "8.10.1"
|
||||
androidx-annotation = "1.6.0"
|
||||
androidx-appcompat = "1.7.0"
|
||||
androidx-autofill = "1.1.0"
|
||||
|
||||
Reference in New Issue
Block a user