Skip to content

fix(android): pin react-android aarMetadata.minCompileSdk to 34#57289

Closed
cortinico wants to merge 1 commit into
mainfrom
nc/minCompileSdk
Closed

fix(android): pin react-android aarMetadata.minCompileSdk to 34#57289
cortinico wants to merge 1 commit into
mainfrom
nc/minCompileSdk

Conversation

@cortinico

Copy link
Copy Markdown
Contributor

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

Test Plan:

CI

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.
@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 Jun 19, 2026
@meta-codesync

meta-codesync Bot commented Jun 19, 2026

Copy link
Copy Markdown

@cortinico has imported this pull request. If you are a Meta employee, you can view this in D109154415.

@meta-codesync meta-codesync Bot closed this in 29e5f95 Jun 19, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 19, 2026
@meta-codesync

meta-codesync Bot commented Jun 19, 2026

Copy link
Copy Markdown

@cortinico merged this pull request in 29e5f95.

leotm added a commit to leotm/react-native-template-new-architecture that referenced this pull request Jul 17, 2026
…1971)

- 0.87.0-nightly-20260519-58cd1bf58 to 0.87.0-nightly-20260705-e04ff69ab
- Revert "Fix RN 0.83 iOS CI hermes-engine pod checksum drift" f8261a5 and resolve conflict
- Bump CocoaPods incl React-Core-prebuilt and hermes-engine to 250829098.0.14
- Disable AGP 9 builtin Kotlin compiler and new DSL
  - fix: Failed to apply plugin 'org.jetbrains.kotlin.android'
    - Cannot add extension with name 'kotlin', as there is an extension already registered with that name
  - force AGP 9 to act like AGP 8 until libs migrated
  - add TODO to revert both flags and old KGP once ecosystem ready
  - ref: react/react-native#56222
- Enable AGP 9 R8 ProguardFile optimization
  - fix: `getDefaultProguardFile('proguard-android.txt')` is no longer supported since it includes `-dontoptimize`, which prevents R8 from performing many optimizations. Instead use `getDefaultProguardFile('proguard-android-optimize.txt)`, and if needed, temporarily use `-dontoptimize` in a custom keep rule file while fixing breakages.
  - improve: startup, memory, rendering and runtime perf, ANRs
- Bump compileSdk and buildTools to 37
  - Android 17 Beta, lvl 37, Cinnamon Bun
  - TODO: add upstream RN CI regression test for react/react-native#57284 (comment) i.e. -Pandroid.compileSdkVersion=36
    - since react/react-native#57289 now -Pandroid.compileSdkVersion=34
- Update jest snapshot
leotm added a commit to leotm/react-native-template-new-architecture that referenced this pull request Jul 17, 2026
…1971)

- 0.87.0-nightly-20260519-58cd1bf58 to 0.87.0-nightly-20260705-e04ff69ab
- Revert "Fix RN 0.83 iOS CI hermes-engine pod checksum drift" f8261a5 and resolve conflict
- Bump CocoaPods incl React-Core-prebuilt and hermes-engine to 250829098.0.14
- Disable AGP 9 builtin Kotlin compiler and new DSL
  - fix: Failed to apply plugin 'org.jetbrains.kotlin.android'
    - cannot add extension with name 'kotlin', as there is an extension already registered with that name
  - force AGP 9 to act like AGP 8 until libs migrated
  - add TODO to revert both flags and old KGP once ecosystem ready
  - ref: react/react-native#56222
- Enable AGP 9 R8 ProguardFile optimization
  - fix: `getDefaultProguardFile('proguard-android.txt')` no longer supported since includes `-dontoptimize` preventing R8 optimizations
    - use `getDefaultProguardFile('proguard-android-optimize.txt)` or temp `-dontoptimize` in a custom keep rule file while fixing breakages
  - improve: startup, memory, rendering and runtime perf, ANRs
- Bump compileSdk and buildTools to 37
  - Android 17 Beta, lvl 37, Cinnamon Bun
  - TODO: add upstream RN CI regression test for react/react-native#57284 (comment) i.e. -Pandroid.compileSdkVersion=36
    - since react/react-native#57289 now -Pandroid.compileSdkVersion=34
- Update jest snapshot
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. Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant