From 2f3ada145f3a717e2a2545e27525e29894787354 Mon Sep 17 00:00:00 2001 From: Hur Ali Date: Tue, 16 Jun 2026 16:58:48 +0500 Subject: [PATCH 1/3] chore: bump example app to Gradle v9.4.1 and use optimize proguard --- FabricExample/android/app/build.gradle | 2 +- FabricExample/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FabricExample/android/app/build.gradle b/FabricExample/android/app/build.gradle index dbe198e54f..5b8eafdd4c 100644 --- a/FabricExample/android/app/build.gradle +++ b/FabricExample/android/app/build.gradle @@ -130,7 +130,7 @@ android { // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" // Detox-specific additions to pro-guard proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" diff --git a/FabricExample/android/gradle/wrapper/gradle-wrapper.properties b/FabricExample/android/gradle/wrapper/gradle-wrapper.properties index 5f38436fc6..c82ad3ff01 100644 --- a/FabricExample/android/gradle/wrapper/gradle-wrapper.properties +++ b/FabricExample/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From f7efb8b4ea6860f13543891faabf1a368e0ab918 Mon Sep 17 00:00:00 2001 From: Hur Ali Date: Tue, 16 Jun 2026 16:59:07 +0500 Subject: [PATCH 2/3] feat: enable opt outs --- FabricExample/android/gradle.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FabricExample/android/gradle.properties b/FabricExample/android/gradle.properties index 38d0ced3c4..b8c8207f37 100644 --- a/FabricExample/android/gradle.properties +++ b/FabricExample/android/gradle.properties @@ -48,3 +48,8 @@ rnsDebugLogsEnabled=true # Use this property to enable V5-specific code rnsGammaEnabled=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 \ No newline at end of file From 4734eb8269429f59df56bd3d920f3f551ff90fe3 Mon Sep 17 00:00:00 2001 From: Hur Ali Date: Tue, 16 Jun 2026 16:59:28 +0500 Subject: [PATCH 3/3] feat: adopt AGP v9 with backward compat --- android/build.gradle | 28 ++++++++++++++----- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 48ed3ad775..c3ef3a0a57 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -86,7 +86,22 @@ if (isRunningInContextOfScreensRepo()) { apply plugin: "com.facebook.react" } apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' + +def shouldEnableAgpFallback() { + def agpMajorVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() + if (agpMajorVersion <= 8) { + return true + } + + def propertyVal = providers.gradleProperty("android.builtInKotlin").orNull + def isBuiltInKotlinEnabled = propertyVal != null ? propertyVal.toBoolean() : true + + return !isBuiltInKotlinEnabled +} + +if (shouldEnableAgpFallback()) { + apply plugin: 'kotlin-android' +} def reactNativeArchitectures() { def value = project.getProperties().get("reactNativeArchitectures") @@ -170,16 +185,15 @@ android { } sourceSets.main { ext.androidResDir = "src/main/res" - java { - srcDirs += [ - "src/fabric/java", - ] + kotlin { + directories.add("src/fabric/java") } res { if (safeExtGet(['compileSdkVersion', 'compileSdk'], rnsDefaultCompileSdkVersion) >= 33) { - srcDirs = ["${androidResDir}/base", "${androidResDir}/v33"] + directories.add("${androidResDir}/base") + directories.add("${androidResDir}/v33") } else { - srcDirs = ["${androidResDir}/base"] + directories.add("${androidResDir}/base") } } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 510e4efae0..221c4f9822 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists