Repository navigation
fix(android): read numeric SDK versions in gradle.properties as integers - #2974
Merged
Tommy Nguyen (tido64) merged 1 commit intoOct 15, 2026
Conversation
`react.compileSdkVersion`, `react.minSdkVersion` and `react.targetSdkVersion`
were published as the raw property strings, while the defaults are integers.
AGP rejects a numeric string `compileSdkVersion` ("Unsupported value: 35"),
and a library whose Kotlin build script reads
`safeExtGet("minSdkVersion", 24) as Int`, such as Reanimated and worklets,
fails with a ClassCastException. Values AGP takes as strings, such as
`android-36.1` or a preview codename, are passed through unchanged.
Contributor
Author
|
@microsoft-github-policy-service agree |
YevheniiKotyrlo
marked this pull request as ready for review
October 15, 2026 03:57
YevheniiKotyrlo
requested review from
Jason Morse (JasonVMo) and
Tommy Nguyen (tido64)
as code owners
October 15, 2026 03:57
Tommy Nguyen (tido64)
merged commit Oct 15, 2026
b345ad7
into
microsoft:trunk
25 of 26 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The SDK versions an app sets with
react.compileSdkVersion,react.minSdkVersionandreact.targetSdkVersion(#2152) are published as the rawgradle.propertiesstrings, while the defaults are integers, so the type ofcompileSdkVersion,minSdkVersionandtargetSdkVersiondepends on whether the app sets them:react.compileSdkVersion=35, the app fails to configure: AGP reads the string as a platform name,Unsupported value: 35. Format must be one of: android-31, ….minSdk = safeExtGet("minSdkVersion", 24) as Intfrom Kotlin build scripts, so an app that setsreact.minSdkVersionfails withclass java.lang.String cannot be cast to class java.lang.Integer.This reads a numeric value as an integer, the type the version-catalog fallback already returns and the one React Native's template uses. Any other value, such as
android-36.1or a preview codename, is passed to AGP unchanged, as today.Platforms affected
Test plan
test/android/dependencies.test.mts(new) prints each SDK version with its class:trunkprintsStringfor all three and Gradle fails on:app'scompileSdkVersion; with this change they areIntegerand the project configures.react.compileSdkVersion=android-36.1, the value stays aStringand the project configures, ontrunkand here.yarn format:js,yarn lint:jsandyarn test:jspass, apart fromnpm pack › includes all files, which fails before it compares any file: my npm printspack --jsonas an object keyed by package name, so[0]is undefined.End to end, react-native-skia's example app (
react.minSdkVersion=26) with Reanimated 4.6.0 and worklets 0.12.2 fails Gradle configuration at Reanimated'sbuild.gradle.kts, and builds with this change.