Android: modernize build stack (AGP 8.7 LTS, targetSdk 35, 16 KB page alignment, RxJava → Coroutines) #791
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
stale
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-streetpea/chiaki-ng!791
Loading…
Reference in a new issue
No description provided.
Delete branch "android/modernization-2026"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the plan from #752. Every change is confined to
android/— no files outside that directory are touched.Why
Two of these are hard Play Store blockers:
.sofiles on Android 15+The rest is the dependency chain needed to get there (AGP 8+ requires JDK 17 and
namespace; Moshi codegen needs Kotlin 1.9; NDK r28 is the first release whose CMake toolchain understandsANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES), plus removing RxJava 2.x, which has been EOL since 2021.Commits
Each commit builds and is independently reviewable. Reviewing commit-by-commit is probably easier than reading the squashed diff.
Phase 0: baseline hygienejcenter()→mavenCentral(), droplifecycle-extensions:2.2.0,-Xuse-experimental→-opt-in,kotlin-stdlib-jdk7→kotlin-stdlib, disable JetifierPhase 1a: AGP 8.7 + Kotlin 1.9 + JDK 17 + namespace + NDK pinningnamespace,plugins {}DSL, pin NDK, Moshi 1.14.0 → 1.15.2, two native-code fixesPhase 1c: targetSdk 35 + edge-to-edge + Predictive BackWindowInsetsControllerCompat,OnBackPressedDispatcher,IntentCompatPhase 3: migrate RxJava2 to Coroutines/FlowFlow/suspend,BehaviorSubject→MutableStateFlow,CompositeDisposable→viewModelScope/lifecycleScope, deleteRxLiveData.kt, AndroidX bumpsPhase 2: version catalog + kapt → KSPgradle/libs.versions.toml, kapt → KSP 1.9.24-1.0.20, Room schema exportPhase 4: minimal test scaffoldingPhase 1b: 16 KB page alignment + Oboe 1.10.0ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON+ explicitmax-page-size/common-page-sizelinker flags, Oboe 1.9.3 → 1.10.0Commit order differs from the numbering in #752 (the numbering was assigned before the work was done); dependency order between commits is correct as committed.
Version changes
Per
CONTRIBUTOR_GUIDE.md, dependency versions were checked in all three places: neither the NDK nor the Oboe version appears in the rootCMakeLists.txt,scripts/, or.github/workflows/— both are declared only underandroid/.Notes on #752
1. No changes needed outside
android/. The original issue asked whether to propagate linker flags into theExternalProject_Addbuilds (Option A/B/C). That turned out to be unnecessary: OpenSSL, json-c, and miniupnpc are all built statically underCHIAKI_ENABLE_ANDROID=ONand linked intolibchiaki-jni.so. The APK ships only three shared libraries per ABI. No coordination oncmake/is required, and none of the three options was needed.2. NDK is pinned to r28c (
28.2.13676358), matching what #752 proposed. r28 is the first release whose CMake toolchain understandsANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES, and its Clang 19 is what the native-code fixes in Phase 1a are for.On the 32-bit question raised in #752 — the answer there was right, with a caveat worth stating precisely, since alignment turns out to depend on where each
.socomes from rather than on the ABI alone. See the table under Verification.Verification
./gradlew testDebugUnitTest testReleaseUnitTest --rerun-tasks— 16 tests per variant, 0 failures, 0 errors../gradlew assembleRelease— BUILD SUCCESSFUL, 0 compiler errors, all four ABIs.Page alignment of every shared library in the release APK — all 12, every LOAD segment (
llvm-readelf -l):Alignment follows the origin of each library, not the ABI:
libchiaki-jni.so0x40000x4000liboboe.so0x40000x4000libc++_shared.soANDROID_STL=c++_shared); outside this project's control0x10000x4000All six 64-bit libraries are 16 KB aligned, which is what the Play requirement covers — 16 KB page devices are arm64-only, so 32-bit code never loads on them. The NDK itself follows this policy: it ships its 64-bit prebuilts 16 KB aligned and leaves the 32-bit ones at 4 KB.
An earlier revision of this description claimed every library in the APK was 16 KB aligned, and listed 8 of the 12 rows. That was wrong on both counts; the two
0x1000rows above are the ones it omitted. The conclusion is unchanged, but the reason is narrower than stated: the linker flags only affectlibchiaki-jni.so, and the other two libraries arrive already aligned (Oboe) or partly aligned (NDK).Dependency health:
Note: this repository has no Android CI workflow, so none of this is verified automatically — the above was run locally (macOS arm64, JDK 17.0.16, NDK r28c, CMake 3.22.1). Happy to add an
androidjob tobuild-pr.yamlas a follow-up PR if you want coverage.What's NOT changing
android/Notes for review
This is one PR rather than the series described in #752. Every commit is scoped to one concern and builds on its own, so it can be reviewed as a chain. If you'd rather have separate PRs, say so and I'll split it — the commits are already partitioned along those lines.
Phase 3 (RxJava removal) is the largest commit and touches every ViewModel, but the changes are mechanical type substitutions with no logic changes. The one place worth a careful look is the JNI boundary:
Session.eventCallbackand theDiscoveryServicehosts callback fire from native threads.MutableStateFlow.value =is thread-safe, soStateFlowreplacesBehaviorSubjectwithout adding a main-thread bounce;MutableLiveData.postValueis retained where it was already used from native callbacks.Closes #752
there is no android version of chiaki-ng but I'll merge this for others that are looking at it...