-
fix(apkbuilder): include native libs in cache identity, hard-fail on 16KB misalignment (#469) (#470)
发布于
2026-08-05 15:29:20 +00:00 An exported NODEJS_APP could reach a 16KB-page Android device with an
unaligned libnode.so and crash at dlopen ("libnode.so 加载失败"). The
export-time ElfAligner16k logic is correct, but a stale unaligned lib
was served from the incremental build cache because identityFingerprint
did not cover native libs — so a host upgrade that shipped a new/aligned
libnode.so did not invalidate the cached unsigned APK (REUSE_UNSIGNED),
and native libs are never re-injected (isContentReplaceableEntry returns
false for lib/*).Changes:
- ApkBuildCache: identityFingerprint() now takes a nativeLibsFingerprint
(sha256 + aligned16k flag of libnode.so / libnode_bridge.so /
libc++_shared.so). A host lib upgrade changes the fingerprint → forces
FULL rebuild → re-inject + realign. Backwards compatible (default
null; old cache meta without the field deserialises as null ≠ new value
→ FULL, the desired behaviour). - ApkBuilder: new nativeLibsFingerprint()/libFingerprint() helpers
compute the per-lib hash + ElfAligner16k.isAligned16k() flag for the
libs injectNodeJsNativeLibs would embed; passed into plan() for
NODEJS_APP only. - ApkBuilder: ZipAligner.alignInPlace failure and
verifyNativeLibAlignment failure now throw IllegalStateException and
abort the build instead of warn-and-continue. A misaligned APK is
guaranteed to crash on Android 15+ (16KB-page) devices at dlopen. - ApkBuildCacheTest: two new tests — native-libs fingerprint change
forces FULL (not REUSE_UNSIGNED); null vs non-null fingerprints differ.
Co-authored-by: shiaho 222622008+shiaho777@users.noreply.github.com
下载附件
- ApkBuildCache: identityFingerprint() now takes a nativeLibsFingerprint