From dce507aae0388ae9922b4dde8a24d9f39434c8c9 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 6 Jul 2026 11:17:23 +0200 Subject: [PATCH] fix(android): opt out of built-in Kotlin See https://github.com/react-native-community/template/commit/775d99aa25b5f6090326db632b6cbc3b246d5e97 --- packages/app/android/app/build.gradle | 2 +- packages/app/android/template.config.mjs | 10 ++++++++++ packages/app/example/android/gradle.properties | 10 ++++++++++ .../app/test/configure/gatherConfig.test.mts.snapshot | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/app/android/app/build.gradle b/packages/app/android/app/build.gradle index 82c87a727..01d94efbc 100644 --- a/packages/app/android/app/build.gradle +++ b/packages/app/android/app/build.gradle @@ -13,7 +13,7 @@ plugins { // Only apply Kotlin plugin if `android.builtInKotlin=false` // https://developer.android.com/build/migrate-to-built-in-kotlin#enable-built-in-kotlin def useBuiltInKotlin = toVersionNumber(gradle.gradleVersion) >= v(9, 4, 0) && - project.findProperty("android.builtInKotlin") != false + project.findProperty("android.builtInKotlin") != "false" if (!useBuiltInKotlin) { apply(plugin: "org.jetbrains.kotlin.android") } diff --git a/packages/app/android/template.config.mjs b/packages/app/android/template.config.mjs index 92c9e00b9..633d7bb94 100644 --- a/packages/app/android/template.config.mjs +++ b/packages/app/android/template.config.mjs @@ -103,6 +103,16 @@ newArchEnabled=true # Version of Kotlin to build against. #KOTLIN_VERSION=1.8.22 + +# Use this property to enable edge-to-edge display support. +# This allows your app to draw behind system bars for an immersive UI. +# Note: Only works with ReactActivity and should not be used with custom Activity. +edgeToEdgeEnabled=true + +# Opt out of built-in kotlin and new DSL behavior that ships with AGP 9. +# Starting from AGP 10.x these opt outs will be removed. +android.builtInKotlin=false +android.newDsl=false `; } diff --git a/packages/app/example/android/gradle.properties b/packages/app/example/android/gradle.properties index a3e761121..997229154 100644 --- a/packages/app/example/android/gradle.properties +++ b/packages/app/example/android/gradle.properties @@ -51,3 +51,13 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # Version of Kotlin to build against. #KOTLIN_VERSION=1.8.22 + +# Use this property to enable edge-to-edge display support. +# This allows your app to draw behind system bars for an immersive UI. +# Note: Only works with ReactActivity and should not be used with custom Activity. +edgeToEdgeEnabled=true + +# Opt out of built-in kotlin and new DSL behavior that ships with AGP 9. +# Starting from AGP 10.x these opt outs will be removed. +android.builtInKotlin=false +android.newDsl=false diff --git a/packages/app/test/configure/gatherConfig.test.mts.snapshot b/packages/app/test/configure/gatherConfig.test.mts.snapshot index 19e6db8f5..b948be79a 100644 --- a/packages/app/test/configure/gatherConfig.test.mts.snapshot +++ b/packages/app/test/configure/gatherConfig.test.mts.snapshot @@ -92,7 +92,7 @@ exports[`gatherConfig() > returns configuration for all platforms 1`] = ` "android/gradle/wrapper/gradle-wrapper.properties": { "source": "example/android/gradle/wrapper/gradle-wrapper.properties" }, - "android/gradle.properties": "# Project-wide Gradle settings.\\n\\n# IDE (e.g. Android Studio) users:\\n# Gradle settings configured through the IDE *will override*\\n# any settings specified in this file.\\n\\n# For more details on how to configure your build environment visit\\n# http://www.gradle.org/docs/current/userguide/build_environment.html\\n\\n# Specifies the JVM arguments used for the Gradle Daemon. The setting is\\n# particularly useful for configuring JVM memory settings for build performance.\\n# This does not affect the JVM settings for the Gradle client VM.\\n# The default is \`-Xmx512m -XX:MaxMetaspaceSize=256m\`.\\norg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\\n\\n# When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute\\n# projects in parallel. To learn more about parallel task execution, see the\\n# section on Gradle build performance:\\n# https://docs.gradle.org/current/userguide/performance.html#parallel_execution.\\n# Default is \`false\`.\\n#org.gradle.parallel=true\\n\\n# AndroidX package structure to make it clearer which packages are bundled with the\\n# Android operating system, and which are packaged with your app's APK\\n# https://developer.android.com/topic/libraries/support-library/androidx-rn\\nandroid.useAndroidX=true\\n# Automatically convert third-party libraries to use AndroidX\\n#android.enableJetifier=true\\n# Jetifier randomly fails on these libraries\\n#android.jetifier.ignorelist=hermes-android,react-android\\n\\n# Use this property to specify which architecture you want to build.\\n# You can also override it from the CLI using\\n# ./gradlew -PreactNativeArchitectures=x86_64\\nreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64\\n\\n# Use this property to enable support to the new architecture.\\n# This will allow you to use TurboModules and the Fabric render in\\n# your application. You should enable this flag either if you want\\n# to write custom TurboModules/Fabric components OR use libraries that\\n# are providing them.\\n# Note that this is incompatible with web debugging.\\nnewArchEnabled=true\\n#bridgelessEnabled=true\\n\\n# Uncomment the line below to build React Native from source.\\n#react.buildFromSource=true\\n\\n# Version of Android NDK to build against.\\n#ANDROID_NDK_VERSION=26.1.10909125\\n\\n# Version of Kotlin to build against.\\n#KOTLIN_VERSION=1.8.22\\n", + "android/gradle.properties": "# Project-wide Gradle settings.\\n\\n# IDE (e.g. Android Studio) users:\\n# Gradle settings configured through the IDE *will override*\\n# any settings specified in this file.\\n\\n# For more details on how to configure your build environment visit\\n# http://www.gradle.org/docs/current/userguide/build_environment.html\\n\\n# Specifies the JVM arguments used for the Gradle Daemon. The setting is\\n# particularly useful for configuring JVM memory settings for build performance.\\n# This does not affect the JVM settings for the Gradle client VM.\\n# The default is \`-Xmx512m -XX:MaxMetaspaceSize=256m\`.\\norg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\\n\\n# When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute\\n# projects in parallel. To learn more about parallel task execution, see the\\n# section on Gradle build performance:\\n# https://docs.gradle.org/current/userguide/performance.html#parallel_execution.\\n# Default is \`false\`.\\n#org.gradle.parallel=true\\n\\n# AndroidX package structure to make it clearer which packages are bundled with the\\n# Android operating system, and which are packaged with your app's APK\\n# https://developer.android.com/topic/libraries/support-library/androidx-rn\\nandroid.useAndroidX=true\\n# Automatically convert third-party libraries to use AndroidX\\n#android.enableJetifier=true\\n# Jetifier randomly fails on these libraries\\n#android.jetifier.ignorelist=hermes-android,react-android\\n\\n# Use this property to specify which architecture you want to build.\\n# You can also override it from the CLI using\\n# ./gradlew -PreactNativeArchitectures=x86_64\\nreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64\\n\\n# Use this property to enable support to the new architecture.\\n# This will allow you to use TurboModules and the Fabric render in\\n# your application. You should enable this flag either if you want\\n# to write custom TurboModules/Fabric components OR use libraries that\\n# are providing them.\\n# Note that this is incompatible with web debugging.\\nnewArchEnabled=true\\n#bridgelessEnabled=true\\n\\n# Uncomment the line below to build React Native from source.\\n#react.buildFromSource=true\\n\\n# Version of Android NDK to build against.\\n#ANDROID_NDK_VERSION=26.1.10909125\\n\\n# Version of Kotlin to build against.\\n#KOTLIN_VERSION=1.8.22\\n\\n# Use this property to enable edge-to-edge display support.\\n# This allows your app to draw behind system bars for an immersive UI.\\n# Note: Only works with ReactActivity and should not be used with custom Activity.\\nedgeToEdgeEnabled=true\\n\\n# Opt out of built-in kotlin and new DSL behavior that ships with AGP 9.\\n# Starting from AGP 10.x these opt outs will be removed.\\nandroid.builtInKotlin=false\\nandroid.newDsl=false\\n", "android/gradlew": { "source": "example/android/gradlew" }, @@ -160,7 +160,7 @@ exports[`gatherConfig() > returns configuration for arbitrary platforms 1`] = ` "android/gradle/wrapper/gradle-wrapper.properties": { "source": "example/android/gradle/wrapper/gradle-wrapper.properties" }, - "android/gradle.properties": "# Project-wide Gradle settings.\\n\\n# IDE (e.g. Android Studio) users:\\n# Gradle settings configured through the IDE *will override*\\n# any settings specified in this file.\\n\\n# For more details on how to configure your build environment visit\\n# http://www.gradle.org/docs/current/userguide/build_environment.html\\n\\n# Specifies the JVM arguments used for the Gradle Daemon. The setting is\\n# particularly useful for configuring JVM memory settings for build performance.\\n# This does not affect the JVM settings for the Gradle client VM.\\n# The default is \`-Xmx512m -XX:MaxMetaspaceSize=256m\`.\\norg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\\n\\n# When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute\\n# projects in parallel. To learn more about parallel task execution, see the\\n# section on Gradle build performance:\\n# https://docs.gradle.org/current/userguide/performance.html#parallel_execution.\\n# Default is \`false\`.\\n#org.gradle.parallel=true\\n\\n# AndroidX package structure to make it clearer which packages are bundled with the\\n# Android operating system, and which are packaged with your app's APK\\n# https://developer.android.com/topic/libraries/support-library/androidx-rn\\nandroid.useAndroidX=true\\n# Automatically convert third-party libraries to use AndroidX\\n#android.enableJetifier=true\\n# Jetifier randomly fails on these libraries\\n#android.jetifier.ignorelist=hermes-android,react-android\\n\\n# Use this property to specify which architecture you want to build.\\n# You can also override it from the CLI using\\n# ./gradlew -PreactNativeArchitectures=x86_64\\nreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64\\n\\n# Use this property to enable support to the new architecture.\\n# This will allow you to use TurboModules and the Fabric render in\\n# your application. You should enable this flag either if you want\\n# to write custom TurboModules/Fabric components OR use libraries that\\n# are providing them.\\n# Note that this is incompatible with web debugging.\\nnewArchEnabled=true\\n#bridgelessEnabled=true\\n\\n# Uncomment the line below to build React Native from source.\\n#react.buildFromSource=true\\n\\n# Version of Android NDK to build against.\\n#ANDROID_NDK_VERSION=26.1.10909125\\n\\n# Version of Kotlin to build against.\\n#KOTLIN_VERSION=1.8.22\\n", + "android/gradle.properties": "# Project-wide Gradle settings.\\n\\n# IDE (e.g. Android Studio) users:\\n# Gradle settings configured through the IDE *will override*\\n# any settings specified in this file.\\n\\n# For more details on how to configure your build environment visit\\n# http://www.gradle.org/docs/current/userguide/build_environment.html\\n\\n# Specifies the JVM arguments used for the Gradle Daemon. The setting is\\n# particularly useful for configuring JVM memory settings for build performance.\\n# This does not affect the JVM settings for the Gradle client VM.\\n# The default is \`-Xmx512m -XX:MaxMetaspaceSize=256m\`.\\norg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\\n\\n# When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute\\n# projects in parallel. To learn more about parallel task execution, see the\\n# section on Gradle build performance:\\n# https://docs.gradle.org/current/userguide/performance.html#parallel_execution.\\n# Default is \`false\`.\\n#org.gradle.parallel=true\\n\\n# AndroidX package structure to make it clearer which packages are bundled with the\\n# Android operating system, and which are packaged with your app's APK\\n# https://developer.android.com/topic/libraries/support-library/androidx-rn\\nandroid.useAndroidX=true\\n# Automatically convert third-party libraries to use AndroidX\\n#android.enableJetifier=true\\n# Jetifier randomly fails on these libraries\\n#android.jetifier.ignorelist=hermes-android,react-android\\n\\n# Use this property to specify which architecture you want to build.\\n# You can also override it from the CLI using\\n# ./gradlew -PreactNativeArchitectures=x86_64\\nreactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64\\n\\n# Use this property to enable support to the new architecture.\\n# This will allow you to use TurboModules and the Fabric render in\\n# your application. You should enable this flag either if you want\\n# to write custom TurboModules/Fabric components OR use libraries that\\n# are providing them.\\n# Note that this is incompatible with web debugging.\\nnewArchEnabled=true\\n#bridgelessEnabled=true\\n\\n# Uncomment the line below to build React Native from source.\\n#react.buildFromSource=true\\n\\n# Version of Android NDK to build against.\\n#ANDROID_NDK_VERSION=26.1.10909125\\n\\n# Version of Kotlin to build against.\\n#KOTLIN_VERSION=1.8.22\\n\\n# Use this property to enable edge-to-edge display support.\\n# This allows your app to draw behind system bars for an immersive UI.\\n# Note: Only works with ReactActivity and should not be used with custom Activity.\\nedgeToEdgeEnabled=true\\n\\n# Opt out of built-in kotlin and new DSL behavior that ships with AGP 9.\\n# Starting from AGP 10.x these opt outs will be removed.\\nandroid.builtInKotlin=false\\nandroid.newDsl=false\\n", "android/gradlew": { "source": "example/android/gradlew" },