Skip to content

Upgrade Gradle to 9.4 (Kotlin 2.3, AGP 9.1, JDK 26)#56222

Draft
leotm wants to merge 2 commits intofacebook:mainfrom
leotm:gradle-9.4
Draft

Upgrade Gradle to 9.4 (Kotlin 2.3, AGP 9.1, JDK 26)#56222
leotm wants to merge 2 commits intofacebook:mainfrom
leotm:gradle-9.4

Conversation

@leotm
Copy link
Copy Markdown
Contributor

@leotm leotm commented Mar 25, 2026

Summary:

Follow-up to

  • bump Gradle wrappers from 9.3.1 to 9.4.0 (root, RNGP, helloworld)
  • bump RNGP: AGP from 8.12.0 to 9.1.0, Kotlin from 2.1.20 to 2.3.0 (RNGP)
  • bump RNGP Kotlin compiler API ver from KOTLIN_1_8 to KOTLIN_2_3 (RNGP)
  • AGP 9 DSL syntax updates
    • NB: AGP 9.1 removed direct prop accessors, replaced by lambdas (DSL closures)
    • ReactPlugin.kt
      • fix: arg type mismatch: actual type is File, String expected
      • old .asFile returns File, directories.add() needs String, use .asFile.absolutePath to convert File to String path
      • NB: AGP 9 replaced .srcDir with directories.add, expects String paths (not File objects)
    • AgpConfiguratorUtils.kt
      • fix: unresolved ref 'namespace', update to lambdas
      • fix: NoSuchMethodError for buildFeatures, 'LibraryBuildFeatures LibraryExtension.getBuildFeatures()', update to lambdas
    • NdkConfiguratorUtils.kt
      • fix: com.android.build.api.dsl. ApplicationBuildFeatures ApplicationExtension.getBuildFeatures breaking rn-tester createBundleReleaseJsAndAssets, update to lambdas
      • fix: com.android.build.api.dsl. ApplicationDefaultConfig ApplicationExtension.getDefaultConfig() breaking rn-tester createBundleReleaseJsAndAssets, update to lambdas
    • ReactAndroid/build.gradle.kts
      • fix: java.exclude Unresolved ref 2 script compilation errors
      • refactor legacy Java source exclusion to explicit filter patterns (Ant-style globs)
      • NB: AGP 9 AndroidSourceDirectorySet stopped extending PatternFilterable
  • JsonUtilsTest.kt
    • fix: :gradle-plugin:shared:compileTestKotlin 40 warnings as errors Unnecessary non-null assertion (!!) on a non-null receiver
    • assert null once at entry point of vars as done in past
  • helloworld
    • fix: Failed to apply plugin 'org.jetbrains.kotlin.android' in :app no longer required for Kotlin support since AGP 9, remove
    • remove from app/build.gradle

Then follow-up react-native-community/template gradlew and kotlinVersion updates
e.g. leotm/react-native-template-new-architecture#1933

Changelog:

[ANDROID] [CHANGED] - Gradle to 9.4.0, Kotlin 2.3.0 and AGP 9.1.0 support

Test Plan:

  • locally (windows 11, CMake: 3.30.5, 4.3.1, JDK 17, JDK 26 security incompatible)
  • .github/actions/build-android/action.yml with prebuilt stable com.facebook.hermes:hermes-android:0.16.0 artifact from mvnrepository.com/artifact/com.facebook.hermes/hermes-android/0.16.0
  • useHermesStable=true, useHermesNightly=false, hermesV1Enabled=false, .hermesversion, version.properties
  • set: ANDROID_SDK_ROOT, JAVA_HOME, NODE_HOME (prepend all to PATH)
  • .\gradlew .\gradlew :private:react-native-fantom:buildFantomTester locally on 0.16.0 tarball 404
  • .\gradlew :packages:react-native:ReactAndroid:tasks
  • .\gradlew :packages:react-native:ReactAndroid:build --dry-run
  • .\gradlew :packages:react-native:ReactAndroid:buildCodegenCLI -PreactNativeArchitectures=arm64-v8a PenableWarningsAsErrors=true --no-daemon
    • fix buildCodegenCLI locally for Windows Git Bash compat
  • .\gradlew :gradle-plugin:react-native-gradle-plugin:compileKotlin -PenableWarningsAsErrors=true --no-daemon
  • .\gradlew :packages:rn-tester:android:app:createBundleReleaseJsAndAssets -PenableWarningsAsErrors=true --no-daemon
  • .\gradlew :packages:react-native:ReactAndroid:buildCMakeDebug[arm64-v8a][hermestooling,jsi,etc] -PenableWarningsAsErrors=true --no-daemon
  • .\gradlew :packages:react-native:ReactAndroid:build -PreactNativeArchitectures=arm64-v8a -PenableWarningsAsErrors=true --no-daemon
  • .github\actions\build-fantom-runner\action.yml locally requires private:react-native-fantom and compiling hermes from source w debug flags (SLOW af)

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 25, 2026
@leotm leotm force-pushed the gradle-9.4 branch 4 times, most recently from 58dc716 to eada3f9 Compare March 31, 2026 20:25
@usta
Copy link
Copy Markdown

usta commented Apr 1, 2026

Gradle 9.4.0 -> 9.4.1
Kotlin 2.3.0 -> 2.3.20

Also agp 9.2 require at least 9.5.x so if this is not so urget it can wait until 9.5.x series became stable ( Right now it is https://github.com/gradle/gradle/releases/tag/v9.5.0-RC1 )

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@leotm leotm force-pushed the gradle-9.4 branch 2 times, most recently from 573ff02 to 9a017c2 Compare April 7, 2026 18:19
## Summary:

Follow-up to
+ facebook#55453
+ react-native-community/template#205

- bump Gradle wrappers from 9.3.1 to 9.4.0 (root, RNGP, helloworld)
- bump RNGP: AGP from 8.12.0 to 9.1.0, Kotlin from 2.1.20 to 2.3.0 (RNGP)
- bump RNGP Kotlin compiler API ver from KOTLIN_1_8 to KOTLIN_2_3 (RNGP)
- AGP 9 DSL syntax updates
  - NB: AGP 9.1 removed direct prop accessors, replaced by lambdas (DSL closures)
  - ReactPlugin.kt
    - fix: arg type mismatch: actual type is File, String expected
    - old .asFile returns File, directories.add() needs String, use .asFile.absolutePath to convert File to String path
    - NB: AGP 9 replaced .srcDir with directories.add, expects String paths (not File objects)
  - AgpConfiguratorUtils.kt
    - fix: unresolved ref 'namespace', update to lambdas
    - fix: NoSuchMethodError for buildFeatures, 'LibraryBuildFeatures LibraryExtension.getBuildFeatures()', update to lambdas
  - NdkConfiguratorUtils.kt
    - fix: com.android.build.api.dsl. ApplicationBuildFeatures ApplicationExtension.getBuildFeatures breaking rn-tester createBundleReleaseJsAndAssets, update to lambdas
    - fix: com.android.build.api.dsl. ApplicationDefaultConfig ApplicationExtension.getDefaultConfig() breaking rn-tester createBundleReleaseJsAndAssets, update to lambdas
  - ReactAndroid/build.gradle.kts
    - fix: java.exclude Unresolved ref 2 script compilation errors
    - refactor legacy Java source exclusion to explicit filter patterns (Ant-style globs)
    - NB: AGP 9 AndroidSourceDirectorySet stopped extending PatternFilterable
- JsonUtilsTest.kt
  - fix: :gradle-plugin:shared:compileTestKotlin 40 warnings as errors Unnecessary non-null assertion (!!) on a non-null receiver
  - assert null once at entry point of vars as done in past

Then follow-up react-native-community/template gradlew and kotlinVersion updates e.g. leotm/react-native-template-new-architecture#1933

## Changelog:

[ANDROID] [CHANGED] - Gradle to 9.4.0, Kotlin 2.3.0 and AGP 9.1.0 support

## Test Plan:

+ template: leotm/react-native-template-new-architecture#1933
- locally (windows 11, CMake: 3.30.5, 4.3.1, JDK 17, JDK 26 security incompatible)
- .github/actions/build-android/action.yml with prebuilt stable com.facebook.hermes:hermes-android:0.16.0 artifact from mvnrepository.com/artifact/com.facebook.hermes/hermes-android/0.16.0
- useHermesStable=true, useHermesNightly=false, hermesV1Enabled=false, .hermesversion, version.properties
- set: ANDROID_SDK_ROOT, JAVA_HOME, NODE_HOME (prepend all to PATH)
- .\gradlew :packages:react-native:ReactAndroid:tasks
- .\gradlew :packages:react-native:ReactAndroid:build --dry-run
- .\gradlew :packages:react-native:ReactAndroid:buildCodegenCLI -PreactNativeArchitectures=arm64-v8a PenableWarningsAsErrors=true --no-daemon
  - fix buildCodegenCLI locally for Windows Git Bash compat
- .\gradlew :gradle-plugin:react-native-gradle-plugin:compileKotlin -PenableWarningsAsErrors=true --no-daemon
- .\gradlew :packages:rn-tester:android:app:createBundleReleaseJsAndAssets -PenableWarningsAsErrors=true --no-daemon
- .\gradlew :packages:react-native:ReactAndroid:buildCMakeDebug[arm64-v8a][hermestooling,jsi,etc] -PenableWarningsAsErrors=true --no-daemon
- .\gradlew :packages:react-native:ReactAndroid:build -PreactNativeArchitectures=arm64-v8a -PenableWarningsAsErrors=true --no-daemon
- .github\actions\build-fantom-runner\action.yml locally requires private:react-native-fantom and compiling hermes from source w debug flags (SLOW af)
@leotm leotm changed the title Bump Gradle to 9.4 (Kotlin to 2.3, AGP to 9.1) Upgrade Gradle to 9.4 (Kotlin to 2.3, AGP to 9.1) Apr 8, 2026
@leotm leotm changed the title Upgrade Gradle to 9.4 (Kotlin to 2.3, AGP to 9.1) Upgrade Gradle to 9.4 (Kotlin 2.3, AGP 9.1. JDK 26) Apr 8, 2026
@leotm leotm changed the title Upgrade Gradle to 9.4 (Kotlin 2.3, AGP 9.1. JDK 26) Upgrade Gradle to 9.4 (Kotlin 2.3, AGP 9.1, JDK 26) Apr 8, 2026
No longer required for Kotlin since AGP 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants