Skip to content

Fix Kotlin 2.3 warnings in Android Gradle builds (#59548) - #59548

Merged
javache merged 1 commit into
react:mainfrom
Abbondanzo:export-D127831836
Oct 28, 2026
Merged

javache merged 1 commit into
react:mainfrom
Abbondanzo:export-D127831836

Conversation

@Abbondanzo

@Abbondanzo Abbondanzo commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Kotlin 2.3 introduced warnings that fail the Android Gradle builds when warnings are treated as errors:

  • API version 2.0 is deprecated. Bump apiVersion to KOTLIN_2_1 in the four gradle-plugin build files, as the previous Kotlin upgrade did when it moved from 1.9 to 2.0. Gradle 9, which React Native requires, ships a Kotlin 2.2 runtime, so the plugin still loads on every supported Gradle version.
  • -Xjvm-default is deprecated in favor of -jvm-default. Replace -Xjvm-default=all in ReactAndroid with its equivalent, jvmDefault = JvmDefaultMode.NO_COMPATIBILITY.
  • Kotlin 2.3 reports more redundant casts, non-null assertions, safe calls and Elvis operators after smart casts or on non-null platform types. Remove them in the gradle-plugin JsonUtilsTest, in ReactAndroid sources (WritableNativeArray, MountItemDispatcher, PreAllocateViewMountItem, AppStateModule, NetworkingModule, UIManagerModule, ReactTextViewAccessibilityDelegate) and in ReactAndroid unit tests (NativeAnimatedNodeTraversalTest, DeviceInfoModuleTest, UIManagerModuleConstantsTest).

Changelog:
[Android][Changed] - Bumped the Gradle plugin minimum Kotlin API version to 2.1

Reviewed By: andrewdacenko

Differential Revision: D127831836

@meta-codesync

meta-codesync Bot commented Oct 27, 2026

Copy link
Copy Markdown

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127831836.

@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 Oct 27, 2026
@meta-codesync meta-codesync Bot changed the title Bump Gradle plugin Kotlin API version from 2.0 to 2.1 Fix Kotlin 2.3 warnings in Android Gradle builds Oct 27, 2026
@Abbondanzo
Abbondanzo force-pushed the export-D127831836 branch 3 times, most recently from e4acf5f to f7f9cf5 Compare October 27, 2026 19:59
Summary:

Kotlin 2.3 introduced warnings that fail the Android Gradle builds when warnings are treated as errors:

- API version 2.0 is deprecated. Bump `apiVersion` to `KOTLIN_2_1` in the four gradle-plugin build files, as the previous Kotlin upgrade did when it moved from 1.9 to 2.0. Gradle 9, which React Native requires, ships a Kotlin 2.2 runtime, so the plugin still loads on every supported Gradle version.
- `-Xjvm-default` is deprecated in favor of `-jvm-default`. Replace `-Xjvm-default=all` in `ReactAndroid` with its equivalent, `jvmDefault = JvmDefaultMode.NO_COMPATIBILITY`.
- Kotlin 2.3 reports more redundant casts, non-null assertions, safe calls and Elvis operators after smart casts or on non-null platform types. Remove them in the gradle-plugin `JsonUtilsTest`, in `ReactAndroid` sources (`WritableNativeArray`, `MountItemDispatcher`, `PreAllocateViewMountItem`, `AppStateModule`, `NetworkingModule`, `UIManagerModule`, `ReactTextViewAccessibilityDelegate`) and in `ReactAndroid` unit tests (`NativeAnimatedNodeTraversalTest`, `DeviceInfoModuleTest`, `UIManagerModuleConstantsTest`).

Changelog:
[Android][Changed] - Bumped the Gradle plugin minimum Kotlin API version to 2.1

Reviewed By: andrewdacenko

Differential Revision: D127831836
@meta-codesync meta-codesync Bot changed the title Fix Kotlin 2.3 warnings in Android Gradle builds Fix Kotlin 2.3 warnings in Android Gradle builds (#59548) Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Visual regression

No visual differences at 0fe823e49857.

ios: no capture

@javache
javache merged commit 3cee68f into react:main Oct 28, 2026
112 of 115 checks passed
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants