Skip to content

Bump Gradle to 9.4 (Kotlin to 2.3, AGP to 9.1)#56222

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

Bump Gradle to 9.4 (Kotlin to 2.3, AGP to 9.1)#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 wrapper 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
  • bump RNGP Kotlin compiler API ver from KOTLIN_1_8 to KOTLIN_2_3
  • ...

Then follow-up react-native-community/template gradlew and kotlinVersion updates

Changelog:

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

Test Plan:

@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 3 times, most recently from a79ccba to 58dc716 Compare March 31, 2026 18:34
## Summary:

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

- bump Gradle wrapper 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
- bump RNGP Kotlin compiler API ver from KOTLIN_1_8 to KOTLIN_2_3
- AGP 9.1 DSL syntax updates
  - ReactPlugin.kt
  - fix: 'Argument type mismatch: actual type is File, but String was expected'
    - AGP 9.1 changed java.srcDir() to use directories.add(), expects String paths (not File objects)
    - old .asFile returns File, directories.add() needs a String - use .asFile.absolutePath to convert File to String path
  - AgpConfiguratorUtils.kt
    - fix: unresolved reference 'namespace'
      - AGP 9.1 removed direct namespace prop from LibraryAndroidComponentsExtension
      - use components.finalizeDsl { dsl -> dsl.namespace = ... }
    - fix: NoSuchMethodError for buildFeatures, 'LibraryBuildFeatures LibraryExtension.getBuildFeatures()'
      - AGP 9.1 removed direct property accessors and changed buildFeatures API to use lambda syntax
      - change `buildFeatures` and `defaultConfig` from direct property assignment to lambda syntax (`ext.buildFeatures { ... }` instead of `ext.buildFeatures`)
      - change `defaultConfig.buildConfigField()` and `defaultConfig.resValue()` to use lambda syntax (`ext.defaultConfig { ... }`)
  - NdkConfiguratorUtils.kt
    - remove deprecated `ext.buildFeatures.prefab = true` (AGP 9.1+ libs declare prefab config directly in their build.gradle)
    - replace direct `cmake.arguments` manipulation with `ext.defaultConfig { }` lambda syntax
    - keep manual CMake argument additions (PROJECT_BUILD_DIR, PROJECT_ROOT_DIR, REACT_ANDROID_DIR, REACT_COMMON_DIR, ANDROID_STL, ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES)
    - NB: AGP 9.1 changed DSL access - `defaultConfig` is now a lambda method, not a direct property
- ReactAndroid/build.gradle.kts
  - remove `java.exclude()` calls for processing and module processing packages causing AGP 9.1 compilation errors
- rn-tester/build.gradle.kts
  - change from `afterEvaluate` block to `tasks.withType<>().configureEach`
  - update task deps to use `configureEach` instead of `getByName()`
  - NB: more reliable task config w AGP 9.1
- JsonUtilsTest.kt
  - fix :gradle-plugin:shared:compileTestKotlin warnings, unnecessary non-null assertion (!!) on a non-null receiver of type '...'
  - causing :packages:rn-tester:android:app:benchmark:stripHermesBenchmarkDebugSymbols to fail then configureCMakeDebug

Then follow-up react-native-community/template gradlew and kotlinVersion updates

## Changelog:

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

## Test Plan:

- leotm/react-native-template-new-architecture#1933
- .github/actions/build-android/action.yml locally with prebuilt hermes-android mvnrepository.com/artifact/com.facebook.hermes/hermes-android/0.16.0
  - JDK 26 sec incompat, JDK 17 ok, prebuilt stable com.facebook.hermes:hermes-android:0.16.0 artifact
  - useHermesStable=true, useHermesNightly=false, hermesV1Enabled=false, .hermesversion, version.properties, skip buildCodegenCLI
  - --dry-run -PreactNativeArchitectures=arm64-v8a -PenableWarningsAsErrors=true
- .github\actions\build-fantom-runner\action.yml locally requires private:react-native-fantom and compiling hermes from source w debug flags (SLOW)
- fix compileTestKotlin warnings by removing redundant null assertions and storing dependencies in local variables
- add generateReactAndroidConfig task to gen ReactAndroidConfig.cmake for find_package() support
- fix CMakeTask configuration to use tasks.configureEach instead of tasks.withType for internal AGP classes
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.

1 participant