Skip to content

Commit 57eb5d6

Browse files
committed
Address review feedback
- Alignment gate: check each archive independently for extracted libraries. `unzip ... || true` (needed because unzip exits 11 on "no matching files") hid the case where a single APK or the AAB shipped no native code at all — the aggregate `checked -eq 0` guard cannot see it, because the remaining archives keep the total non-zero. Reproduced against the previous gate: an APK containing zero .so alongside one good APK printed "All 1 native libraries are 16 KB-aligned" and exited 0. Now fails, naming the archive. - Reword the summary from "$bad segment(s) are not 16 KB-aligned" to "$bad problem(s) found": `bad` also counts archives with no libraries and files objdump cannot read, so the old wording misreported those failures. - docs: the manual signing walkthrough still used `zipalign -p -f 4`, the very 4 KB-only flag this PR replaces with `-P 16` in CI. Anyone signing a release by following the docs would have produced exactly the artifact Play rejects.
1 parent 7aa2b79 commit 57eb5d6

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

.github/workflows/android.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,23 @@ jobs:
183183
# receives — and it stores libraries under `base/lib/<abi>/`, not
184184
# `lib/<abi>/`, so it needs its own extract pattern. Checking only the
185185
# APKs would leave the Play artifact unverified.
186+
#
187+
# Each archive extracts into its own subdirectory and is checked for a
188+
# non-empty result immediately. `unzip || true` is needed because
189+
# unzip exits 11 on "no matching files", but that is exactly the
190+
# symptom of an archive shipping no native code at all — a worse
191+
# regression than misalignment. The aggregate `checked -eq 0` guard
192+
# below cannot catch it, since the other archives still contribute
193+
# libraries and the total stays non-zero.
186194
archives=0
187195
while IFS= read -r apk; do
188196
archives=$((archives + 1))
189-
unzip -o -q "$apk" 'lib/*/*.so' -d "$workdir/$archives" || true
197+
dest="$workdir/$archives"
198+
unzip -o -q "$apk" 'lib/*/*.so' -d "$dest" || true
199+
if [ "$(find "$dest" -name '*.so' 2>/dev/null | wc -l)" -eq 0 ]; then
200+
echo "::error::$apk contains no native libraries under lib/"
201+
bad=$((bad + 1))
202+
fi
190203
done < <(find apps/geolibre-desktop/src-tauri/gen/android \
191204
-name '*release*.apk')
192205
if [ "$archives" -eq 0 ]; then
@@ -197,7 +210,12 @@ jobs:
197210
# is not an error — but when present it must be verified too.
198211
while IFS= read -r aab; do
199212
archives=$((archives + 1))
200-
unzip -o -q "$aab" 'base/lib/*/*.so' -d "$workdir/$archives" || true
213+
dest="$workdir/$archives"
214+
unzip -o -q "$aab" 'base/lib/*/*.so' -d "$dest" || true
215+
if [ "$(find "$dest" -name '*.so' 2>/dev/null | wc -l)" -eq 0 ]; then
216+
echo "::error::$aab contains no native libraries under base/lib/"
217+
bad=$((bad + 1))
218+
fi
201219
done < <(find apps/geolibre-desktop/src-tauri/gen/android \
202220
-path '*/outputs/bundle/*' -name '*.aab')
203221
while IFS= read -r so; do
@@ -241,7 +259,10 @@ jobs:
241259
exit 1
242260
fi
243261
if [ "$bad" -gt 0 ]; then
244-
echo "::error::$bad segment(s) are not 16 KB-aligned; Play will reject this build"
262+
# "problem(s)", not "segment(s)": $bad now also counts archives that
263+
# shipped no native libraries and files objdump could not read, not
264+
# just misaligned segments.
265+
echo "::error::$bad problem(s) found; Play will reject this build"
245266
exit 1
246267
fi
247268
echo "All $checked native libraries are 16 KB-aligned."

docs/android.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ testing; use a real key for distribution):
130130
```bash
131131
BT="$ANDROID_HOME/build-tools/36.0.0"
132132
KS="$HOME/.android/debug.keystore" # auto-created by Android tooling; or make your own
133-
"$BT/zipalign" -p -f 4 app-arm64-release-unsigned.apk aligned.apk
133+
# -P 16, not -p: -p only guarantees 4 KB, and Play requires the .so to sit on a
134+
# 16 KB boundary inside the zip. Same flag CI uses.
135+
"$BT/zipalign" -P 16 -f 4 app-arm64-release-unsigned.apk aligned.apk
134136
"$BT/apksigner" sign --ks "$KS" --ks-pass pass:android \
135137
--ks-key-alias androiddebugkey --key-pass pass:android \
136138
--out geolibre-arm64.apk aligned.apk

0 commit comments

Comments
 (0)