Skip to content

Commit 29e5f95

Browse files
cortinicometa-codesync[bot]
authored andcommitted
fix(android): pin react-android aarMetadata.minCompileSdk to 34 (#57289)
Summary: AGP 9 changed the default so a library propagates a minCompileSdk equal to its own compileSdk. Since react-android compiles against compileSdk 36, this now forces every consuming library/app to compileSdk >= 36 (e.g. it breaks libraries still on compileSdk 35 at checkAarMetadata). RN does not actually require API 36: its public ABI exposes no android type newer than ~API 23, the highest framework constant referenced in code is UPSIDE_DOWN_CAKE (34), and the source is deliberately written to compile against SDK 34 (see util/AndroidVersion.kt, which abstracts the 35/36 version codes and the API-35 windowOptOutEdgeToEdgeEnforcement attribute). compileSdk is 36 only to build against the latest platform. Set minCompileSdk = 34 explicitly to restore the pre-AGP-9 behavior and avoid needlessly forcing the library ecosystem onto compileSdk 36. The binary-compatibility-validator dump (ReactAndroid.api) guards against future regressions: adding an API 35/36 type to the public ABI would change that file and signal that this floor must rise. ## Changelog: [ANDROID] [CHANGED] - Set minCompileSdk to 34, libraries will have to specify a compileSdk of >= 34 in order to work with React Native Pull Request resolved: #57289 Test Plan: CI Reviewed By: javache Differential Revision: D109154415 Pulled By: cortinico fbshipit-source-id: f25e0a1992c450bfab83211ea6245375858b8895
1 parent c6110b1 commit 29e5f95

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ android {
553553
defaultConfig {
554554
minSdk = libs.versions.minSdk.get().toInt()
555555

556+
aarMetadata {
557+
// RN's public ABI exposes no android API newer than 34, and the source is written to
558+
// compile against SDK 34 (see util/AndroidVersion.kt). compileSdk is 36 only to build
559+
// against the latest platform — it is not an API requirement. Without this, AGP 9
560+
// defaults minCompileSdk to compileSdk (36), needlessly forcing every consuming
561+
// library/app to compileSdk 36.
562+
minCompileSdk = 34
563+
}
564+
556565
consumerProguardFiles("proguard-rules.pro")
557566

558567
buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")

0 commit comments

Comments
 (0)