Skip to content

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

Draft
leotm wants to merge 10 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 10 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
@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 )

leotm added 2 commits April 4, 2026 18:43
- use tasks.withType<Task>().configureEach instead of tasks.configureEach to properly find lazily created CMake tasks in AGP 9.1+
- use ${CMAKE_ANDROID_ARCH_ABI} variable instead of hardcoded armeabi-v7a for architecture-agnostic paths
- use correct prefab lib path: build/intermediates/prefab_package/debug/prefab/modules/
- convert Windows paths to forward slashes for CMake compat
- use ${'$'}{CMAKE_ANDROID_ARCH_ABI} variable for architecture-agnostic paths
@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 added 6 commits April 4, 2026 20:05
- download and extract fbjni AAR headers for prefab
- add fbjni to ReactAndroid's prefab block
- update ReactAndroidConfig.cmake to expose fbjni
- extract .so files from fbjni AAR to build/intermediates/prefab_package/
- ensure find_package(fbjni REQUIRED CONFIG) works correctly
- ensure ReactAndroidConfig.cmake is generated before rn-tester's CMake runs
- fix 'ReactAndroid::jsi' and 'ReactAndroid::reactnative' targets not found
- more reliable for AGP 9.1+ lazy task creation
- ensures generateReactAndroidConfig runs before CMake tasks
- add missing imports for java.util.zip.ZipEntry and ZipFile
- add explicit type annotation ZipEntry to the lambda parameter
- replace entry.isDirectory with !entry.name.endsWith("/") since ZipEntry has no isDirectory property
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