Skip to content

fix(android): read numeric SDK versions in gradle.properties as integers - #2974

Merged
Tommy Nguyen (tido64) merged 1 commit into
microsoft:trunkfrom
YevheniiKotyrlo:fix/android-sdk-version-integers
Oct 15, 2026
Merged

Tommy Nguyen (tido64) merged 1 commit into
microsoft:trunkfrom
YevheniiKotyrlo:fix/android-sdk-version-integers

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor

Description

The SDK versions an app sets with react.compileSdkVersion, react.minSdkVersion and react.targetSdkVersion (#2152) are published as the raw gradle.properties strings, while the defaults are integers, so the type of compileSdkVersion, minSdkVersion and targetSdkVersion depends on whether the app sets them:

  • With 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, ….
  • Reanimated 4.4+ and worklets 0.9.1+ read minSdk = safeExtGet("minSdkVersion", 24) as Int from Kotlin build scripts, so an app that sets react.minSdkVersion fails with class 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.1 or a preview codename, is passed to AGP unchanged, as today.

Platforms affected

  • Android
  • iOS
  • macOS
  • visionOS
  • Windows

Test plan

test/android/dependencies.test.mts (new) prints each SDK version with its class:

  • With the three properties set to numbers, trunk prints String for all three and Gradle fails on :app's compileSdkVersion; with this change they are Integer and the project configures.
  • With react.compileSdkVersion=android-36.1, the value stays a String and the project configures, on trunk and here.

yarn format:js, yarn lint:js and yarn test:js pass, apart from npm pack › includes all files, which fails before it compares any file: my npm prints pack --json as 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's build.gradle.kts, and builds with this change.

`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.
@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@tido64 Tommy Nguyen (tido64) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tido64
Tommy Nguyen (tido64) merged commit b345ad7 into microsoft:trunk Oct 15, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants