Skip to content

android: read abiFilters from reactNativeArchitectures (#30)#35

Merged
achou11 merged 2 commits into
mainfrom
claude/hungry-boyd-e242a7
Apr 29, 2026
Merged

android: read abiFilters from reactNativeArchitectures (#30)#35
achou11 merged 2 commits into
mainfrom
claude/hungry-boyd-e242a7

Conversation

@gmaclennan

@gmaclennan gmaclennan commented Apr 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the hardcoded ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' at android/build.gradle:52 with the canonical RN helper that reads the reactNativeArchitectures gradle property — same convention used by react-native core, expo-modules-core, react-native-mmkv, react-native-skia, react-native-reanimated, react-native-vision-camera, op-sqlite, react-native-quick-crypto, and realm-js.
  • Adds packagingOptions.excludes rules for ABIs outside the resolved set, so reactNativeArchitectures actually narrows the AAR. Empirical AAR inspection showed that defaultConfig.ndk.abiFilters on a library module does not filter prebuilt .so content from jniLibs.srcDirspackagingOptions.excludes is what works.
  • Consumers can now ship a narrower ABI set (e.g. arm64-only release builds) by setting reactNativeArchitectures in android/gradle.properties or passing -PreactNativeArchitectures=..., without forking.
  • Closes Read abiFilters from consuming app's build.gradle #30.

Why two deviations from the canonical reactNativeArchitectures helper

We ship ~155 MB of prebuilt .so for a narrower ABI set than RN's default, so the standard helper alone would silently break:

  • Fallback is our three prebuilt ABIs (armeabi-v7a, arm64-v8a, x86_64), not the canonical four. x86 is excluded because scripts/build-backend.ts does not fetch x86 prebuilds — defaulting to it would produce a missing-.so runtime crash.
  • Requested set is intersected with the supported set. Unsupported ABIs (e.g. x86 from a stock expo prebuild gradle.properties) are dropped with a logger.warn. An empty intersection throws GradleException with a clear message.

Verified build-time win

With -PreactNativeArchitectures=arm64-v8a against example/android (clean rebuilds of :comapeo-core-react-native:bundleDebugAar):

Override AAR size .so payload armeabi-v7a arm64-v8a x86_64
(none) 58 MB 155 MB 47 MB 52 MB 56 MB
-PreactNativeArchitectures=arm64-v8a 22 MB 52 MB 52 MB

.so payload drops to ~⅓ (matching the verification claim). Downstream, :app:mergeDebugNativeLibs confirms the comapeo contribution drops from ~155 MB to ~52 MB at app build time.

Note: the per-library merged_jni_libs intermediate (the mergeDebugJniLibFolders task output) does not shrink — AGP's merge step always copies the full jniLibs.srcDirs. The savings come at AAR-pack and app-pack time.

Test plan

Verified end-to-end against example/android after npx expo prebuild --platform android:

  • Default (no -P) — stock gradle.properties declares all 4 RN ABIs; library prints comapeo-core-react-native: dropping unsupported ABIs x86 from reactNativeArchitectures; building armeabi-v7a, arm64-v8a, x86_64. and produces a 58 MB AAR with all 3 ABIs.
  • -PreactNativeArchitectures=arm64-v8a — narrows cleanly with no warning, AAR drops to 22 MB and contains only arm64-v8a.
  • -PreactNativeArchitectures=x86 — fails with reactNativeArchitectures=x86 has no overlap with the ABIs comapeo-core-react-native ships prebuilds for (armeabi-v7a, arm64-v8a, x86_64).
  • Closure logic exercised standalone in a scratch gradle project across 6 input cases (none, narrow, mixed, all-4-RN, whitespace, fully-unsupported).
  • AAR-content verification via unzip -l … | grep '\.so' for both default and arm64-only builds.
  • CI Android workflow green.

🤖 Generated with Claude Code

gmaclennan and others added 2 commits April 28, 2026 23:08
Replaces the hardcoded `ndk.abiFilters 'armeabi-v7a', 'arm64-v8a',
'x86_64'` in `android/build.gradle` with the canonical RN helper that
reads the `reactNativeArchitectures` gradle property — same convention
used by `react-native` core, `expo-modules-core`, `react-native-mmkv`,
`react-native-skia`, `react-native-reanimated`, `react-native-vision-
camera`, `op-sqlite`, `react-native-quick-crypto`, and `realm-js`.

Two scoped deviations from the canonical helper, both because we ship
~120 MB of prebuilt `.so` for a narrower ABI set than RN's default:

- Fallback is the three ABIs we actually fetch in
  `scripts/build-backend.ts` (`armeabi-v7a, arm64-v8a, x86_64`), not the
  canonical four. `x86` is excluded because no prebuild exists for it.
- The requested set is intersected with that supported set; unsupported
  ABIs are dropped with a `logger.warn`, and an empty intersection
  throws `GradleException` with a clear message.

Side effect: the existing CI flag `-PreactNativeArchitectures=x86_64`
in `.github/workflows/` was previously a no-op against the library —
it'll now actually narrow the library build, cutting `merged_jni_libs`
and AAR I/O by roughly two-thirds on every CI run.

Closes #30

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Empirical AAR inspection showed that `defaultConfig.ndk.abiFilters` on
a library module does *not* filter prebuilt `.so` content from
`jniLibs.srcDirs` — confirmed by building with
`-PreactNativeArchitectures=arm64-v8a` and unzipping the resulting
AAR, which still contained all three supported ABIs (~155 MB of `.so`
across `armeabi-v7a / arm64-v8a / x86_64`).

`packagingOptions.excludes` *does* filter at AAR pack time. Add an
`excludes` rule for each ABI in `supportedAbis - comapeoAbiFilters`,
which lets `reactNativeArchitectures` actually narrow what the AAR
ships.

Verified end-to-end via clean rebuilds of `:comapeo-core-react-native:bundleDebugAar`
in `example/android`:

| Override                                | AAR size | .so total |
| --------------------------------------- | -------- | --------- |
| (none)                                  | 58 MB    | 155 MB    |
| `-PreactNativeArchitectures=arm64-v8a`  | 22 MB    |  52 MB    |

→ ~⅓ of the original `.so` payload, matching the verification claim
in the PR. App-level `:app:mergeDebugNativeLibs` confirms the comapeo
contribution drops from ~155 MB to ~52 MB downstream.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@achou11 achou11 merged commit cb1b78f into main Apr 29, 2026
7 checks passed
@achou11 achou11 deleted the claude/hungry-boyd-e242a7 branch April 29, 2026 09:51
gmaclennan added a commit that referenced this pull request Jun 22, 2026
## Optic Release Automation

This **draft** PR is opened by Github action
[optic-release-automation-action](https://github.com/nearform-actions/optic-release-automation-action).

A new **draft** GitHub release
[v1.0.0-pre.2](https://github.com/digidem/comapeo-core-react-native/releases/tag/untagged-c499977757c9745e56b2)
has been created.

Release author: @gmaclennan

#### If you want to go ahead with the release, please merge this PR.
When you merge:

- The GitHub release will be published

- The npm package with tag pre will be published according to the
publishing rules you have configured



- No major or minor tags will be updated as configured


#### If you close the PR

- The new draft release will be deleted and nothing will change

## What's Changed
* Android Testing Infrastructure & Bug Fixes by @gmaclennan in
#3
* chore: prebuild example/android; harden instrumented tests by
@gmaclennan in
#10
* Integrate @comapeo/core via IPC over Unix sockets by @gmaclennan in
#5
* chore: adjust repo setup by @achou11 in
#12
* chore: minor fixes based on expo-doctor by @achou11 in
#13
* Add iOS support & test infrastructure by @gmaclennan in
#6
* chore: add architecture docs & plans by @gmaclennan in
#11
* update some native deps used in backend by @achou11 in
#14
* iOS Phase 1: unified JS bundle + smoke test (simulator-only) by
@gmaclennan in
#15
* iOS Phase 2: xcframework Embed & Sign for native addons by @gmaclennan
in #16
* Phase 2 Android: jniLibs packaging + unified rollup loader plugin by
@gmaclennan in
#17
* chore: post-Phase-2 cleanup — comments, plan docs, agents.md by
@gmaclennan in
#33
* android: read abiFilters from reactNativeArchitectures (#30) by
@gmaclennan in
#35
* refactor: simplify build-backend.ts; rollup writes directly to native
asset trees by @gmaclennan in
#34
* chore: fix eslint configuration by @achou11 in
#41
* android: audit 16 KB page alignment on every shipped .so by
@gmaclennan in
#43
* Add rootkey persistence and lifecycle state management by @gmaclennan
in #36
* chore: move example app into apps directory by @achou11 in
#18
* refactor: per-component lifecycle state with derived ComapeoState by
@gmaclennan in
#47
* android: fold waitForFile into connect retry loop by @gmaclennan in
#52
* chore: add e2e testing app by @achou11 in
#49
* fix(android): drop setUnlockedDeviceRequired from rootkey wrapper key
by @gmaclennan in
#57
* fix(backend): cache stopping/error frames for late joiners by
@gmaclennan in
#58
* fix(ios-tests): wait for STOPPING before signalling node exit by
@gmaclennan in
#59
* fix(android): drain JNI stdio pumps before returning from node::Start
by @gmaclennan in
#60
* Sentry integration: Phase 1 + Phase 2a + Phase 2b by @gmaclennan in
#54
* feat(backend): polywasm-backed undici on iOS, re-enable maps plugin by
@gmaclennan in
#62
* ci: drop unreliable Android emulator snapshot caching by @gmaclennan
in #64
* feat(sentry): land Phase 3 — backend loader + RPC tracing by
@gmaclennan in
#63
* fix(ios-tests): serialise STOPPING/STOPPED observers in
testFullLifecycleStateTransitions by @gmaclennan in
#71
* use npm list instead of custom traversal to get native module versions
by @achou11 in
#70
* feat(sentry): land Phases 6 + 7a — Android exit reasons & iOS
MetricKit app-exit telemetry by @gmaclennan in
#72
* fix(sentry): make exit telemetry lossless and stop cross-process
clobbering by @gmaclennan in
#84
* chore(e2e): add e2e tests on browserstack via Maestro by @achou11 in
#56
* feat(sentry): migrate to @sentry/react-native v8; exit telemetry as
Application Metrics by @gmaclennan in
#73
* Map server integration by @gmaclennan in
#86
* chore(deps): upgrade to Expo SDK 56 (React Native 0.85) by @gmaclennan
in #87
* chore(ci): add release workflow by @gmaclennan in
#90
* chore: fix npm script and release build script by @gmaclennan in
#91
* chore(pack): don't try to package build files by @gmaclennan in
#92
* fix: start fastify listening by @gmaclennan in
#93
* perf(backend): switch bundler from rollup to rolldown by @gmaclennan
in #94
* fix(ci): ignore-scripts in ios npm installs by @gmaclennan in
#96
* fix(ci): replace --ignore-scripts with npm strict-allow-scripts
allowlist by @gmaclennan in
#106
* feat(config): let the consuming app supply the default project config
by @gmaclennan in
#95
* chore(release): merge prerelease branch. by @gmaclennan in
#110

## New Contributors
* @achou11 made their first contribution in
#12

**Full Changelog**:
https://github.com/digidem/comapeo-core-react-native/commits/v1.0.0-pre.2

<!--

<release-meta>{"id":342868678,"version":"v1.0.0-pre.2","npmTag":"pre","opticUrl":"https://optic-zf3votdk5a-ew.a.run.app/api/generate/"}</release-meta>
-->
@gmaclennan gmaclennan added the feature New feature (changelog) label Jun 22, 2026
gmaclennan added a commit that referenced this pull request Jun 22, 2026
## Optic Release Automation

This **draft** PR is opened by Github action
[optic-release-automation-action](https://github.com/nearform-actions/optic-release-automation-action).

A new **draft** GitHub release
[v1.0.0-pre.2](https://github.com/digidem/comapeo-core-react-native/releases/tag/untagged-352a6c41c12fd02dec37)
has been created.

Release author: @gmaclennan

#### If you want to go ahead with the release, please merge this PR.
When you merge:

- The GitHub release will be published

- The npm package with tag pre will be published according to the
publishing rules you have configured



- No major or minor tags will be updated as configured


#### If you close the PR

- The new draft release will be deleted and nothing will change

<!-- Release notes generated using configuration in .github/release.yml
at 7fe80b4 -->

## What's Changed
### 🚀 Features
* Integrate @comapeo/core via IPC over Unix sockets by @gmaclennan in
#5
* Add iOS support & test infrastructure by @gmaclennan in
#6
* iOS Phase 1: unified JS bundle + smoke test (simulator-only) by
@gmaclennan in
#15
* iOS Phase 2: xcframework Embed & Sign for native addons by @gmaclennan
in #16
* Phase 2 Android: jniLibs packaging + unified rollup loader plugin by
@gmaclennan in
#17
* android: read abiFilters from reactNativeArchitectures (#30) by
@gmaclennan in
#35
* Add rootkey persistence and lifecycle state management by @gmaclennan
in #36
* Sentry integration: Phase 1 + Phase 2a + Phase 2b by @gmaclennan in
#54
* feat(backend): polywasm-backed undici on iOS, re-enable maps plugin by
@gmaclennan in
#62
* feat(sentry): land Phase 3 — backend loader + RPC tracing by
@gmaclennan in
#63
* feat(sentry): land Phases 6 + 7a — Android exit reasons & iOS
MetricKit app-exit telemetry by @gmaclennan in
#72
* feat(sentry): migrate to @sentry/react-native v8; exit telemetry as
Application Metrics by @gmaclennan in
#73
* Map server integration by @gmaclennan in
#86
* feat(config): let the consuming app supply the default project config
by @gmaclennan in
#95
### 🐛 Bug Fixes
* fix(android): drop setUnlockedDeviceRequired from rootkey wrapper key
by @gmaclennan in
#57
* fix(backend): cache stopping/error frames for late joiners by
@gmaclennan in
#58
* fix(ios-tests): wait for STOPPING before signalling node exit by
@gmaclennan in
#59
* fix(android): drain JNI stdio pumps before returning from node::Start
by @gmaclennan in
#60
* fix(ios-tests): serialise STOPPING/STOPPED observers in
testFullLifecycleStateTransitions by @gmaclennan in
#71
* fix(sentry): make exit telemetry lossless and stop cross-process
clobbering by @gmaclennan in
#84
* fix: start fastify listening by @gmaclennan in
#93
* fix(ci): ignore-scripts in ios npm installs by @gmaclennan in
#96
* fix(ci): replace --ignore-scripts with npm strict-allow-scripts
allowlist by @gmaclennan in
#106
* fix(release): stop `npm pack --dry-run` leaking dry-run into backend
install by @gmaclennan in
#129
### ⚡ Performance
* perf(backend): switch bundler from rollup to rolldown by @gmaclennan
in #94
### ⬆️ Dependencies
* update some native deps used in backend by @achou11 in
#14
* chore(deps): upgrade to Expo SDK 56 (React Native 0.85) by @gmaclennan
in #87
### 🏗️ Maintenance
* Android Testing Infrastructure & Bug Fixes by @gmaclennan in
#3
* chore: prebuild example/android; harden instrumented tests by
@gmaclennan in
#10
* chore: adjust repo setup by @achou11 in
#12
* chore: minor fixes based on expo-doctor by @achou11 in
#13
* chore: add architecture docs & plans by @gmaclennan in
#11
* chore: post-Phase-2 cleanup — comments, plan docs, agents.md by
@gmaclennan in
#33
* refactor: simplify build-backend.ts; rollup writes directly to native
asset trees by @gmaclennan in
#34
* chore: fix eslint configuration by @achou11 in
#41
* android: audit 16 KB page alignment on every shipped .so by
@gmaclennan in
#43
* chore: move example app into apps directory by @achou11 in
#18
* refactor: per-component lifecycle state with derived ComapeoState by
@gmaclennan in
#47
* android: fold waitForFile into connect retry loop by @gmaclennan in
#52
* chore: add e2e testing app by @achou11 in
#49
* ci: drop unreliable Android emulator snapshot caching by @gmaclennan
in #64
* use npm list instead of custom traversal to get native module versions
by @achou11 in
#70
* chore(e2e): add e2e tests on browserstack via Maestro by @achou11 in
#56
* chore(ci): add release workflow by @gmaclennan in
#90
* chore: fix npm script and release build script by @gmaclennan in
#91
* chore(pack): don't try to package build files by @gmaclennan in
#92
* chore(release): merge prerelease branch. by @gmaclennan in
#110
* ci(e2e): retry BrowserStack builds on infra-class flakes by
@gmaclennan in
#113
### Other Changes
* ci: derive changelog labels from PR titles + add Dependabot by
@gmaclennan in
#114

## New Contributors
* @achou11 made their first contribution in
#12
* @optic-release-automation[bot] made their first contribution in
#112

**Full Changelog**:
https://github.com/digidem/comapeo-core-react-native/commits/v1.0.0-pre.2

<!--

<release-meta>{"id":342970724,"version":"v1.0.0-pre.2","npmTag":"pre","opticUrl":"https://optic-zf3votdk5a-ew.a.run.app/api/generate/"}</release-meta>
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (changelog)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read abiFilters from consuming app's build.gradle

2 participants