Skip to content

Commit 69dc655

Browse files
cortinicometa-codesync[bot]
authored andcommitted
RNGP - Fix build failures encounted with AGP 9.0.0-alpha05 - Round 1 (#53778)
Summary: Pull Request resolved: #53778 I've been looking into the next major bump of AGP to 9: https://developer.android.com/build/releases/agp-preview#android-gradle-plugin-built-in-kotlin This change adapts our project so that it keeps on buildign with AGP 8 (as the bump to 9 would be a breaking change), but it addresses some of the build failures we'll be having with AGP 9: - Set `resValues` build option to true (default was changed true -> false in AGP 9) - Opts out our project from `android.builtInKotlin` and `android.newDsl` for the time being. Changelog: [Android] [Fixed] - Fix build failures with RNGP due to AGP 9.0.0-alpha05 Reviewed By: alanleedev Differential Revision: D82452555 fbshipit-source-id: 99561f039bf943f5ce99008ce073ca86431cfaed
1 parent b44d4b4 commit 69dc655

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ org.gradle.caching=true
44

55
android.useAndroidX=true
66

7+
# Those 2 properties are needed to make our project compatible with
8+
# AGP 9.0.0 for the time being. Ideally we should not opt-out of
9+
# builtInKotlin and newDsl once AGP 9.0.0 hits stable.
10+
# More on this: https://developer.android.com/build/releases/agp-preview#android-gradle-plugin-built-in-kotlin
11+
android.builtInKotlin=false
12+
android.newDsl=false
13+
714
# Use this property to specify which architecture you want to build.
815
# You can also override it from the CLI using
916
# ./gradlew <task> -PreactNativeArchitectures=x86_64

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ internal object AgpConfiguratorUtils {
100100
project.extensions
101101
.getByType(ApplicationAndroidComponentsExtension::class.java)
102102
.finalizeDsl { ext ->
103+
ext.buildFeatures.resValues = true
103104
ext.defaultConfig.resValue(
104105
"string",
105106
"react_native_dev_server_ip",

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,13 @@ android {
532532
targetCompatibility = JavaVersion.VERSION_17
533533
}
534534

535-
kotlinOptions {
536-
// Using '-Xjvm-default=all' to generate default java methods for interfaces
537-
freeCompilerArgs = listOf("-Xjvm-default=all")
538-
// Using -PenableWarningsAsErrors=true prop to enable allWarningsAsErrors
539-
kotlinOptions.allWarningsAsErrors = enableWarningsAsErrors()
535+
kotlin {
536+
compilerOptions {
537+
// Using '-Xjvm-default=all' to generate default java methods for interfaces
538+
freeCompilerArgs = listOf("-Xjvm-default=all")
539+
// Using -PenableWarningsAsErrors=true prop to enable allWarningsAsErrors
540+
allWarningsAsErrors = enableWarningsAsErrors()
541+
}
540542
}
541543

542544
defaultConfig {
@@ -637,6 +639,7 @@ android {
637639
prefab = true
638640
prefabPublishing = true
639641
buildConfig = true
642+
resValues = true
640643
}
641644

642645
prefab {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/CxxInspectorPackagerConnection.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import okhttp3.WebSocket
2222
import okhttp3.WebSocketListener
2323

2424
/** Java wrapper around a C++ InspectorPackagerConnection. */
25+
@DoNotStripAny
2526
internal class CxxInspectorPackagerConnection(
2627
url: String,
2728
deviceName: String,

0 commit comments

Comments
 (0)