Files
sx/examples/1666-platform-android-apk-smoke.sx
agra 2ba36f6562 P5.8: add an Android .apk bundle smoke test to the corpus (first Android bundler coverage)
Mirror the macOS .app smoke test (1665) for Android. New `.build` `apk`
directive (ApkCheck = { out, bundle_id, expect }) cross-compiles via
`sx build --target android --apk ... --bundle-id ... -o lib*.so`, then
asserts the produced APK's zip entries (AndroidManifest.xml, classes.dex,
lib/arm64-v8a/) via `unzip -l`. Build+inspect only — aarch64-linux-android
can't execute on the host, so no exit/stdout/stderr snapshot; the apk
branch is self-contained and never falls through to stream comparison.

Gated on the Android SDK ($ANDROID_HOME / $ANDROID_SDK_ROOT /
~/Library/Android/sdk) AND a real JDK (`javac -version` exit 0 — the
macOS /usr/bin/javac stub fails the gate). Missing either → skip cleanly,
so a bare-host `zig build test` stays green. Cleanup rm -rf's the apk,
staged .so, .stage dir, .unaligned/.aligned intermediates, and the
apksigner .idsig sidecar.

Verified: default `zig build test` skips 1666 (709 examples ran, 0 failed;
476/476 unit). With JAVA_HOME set to Android Studio's jbr, 1666 RUNS and
PASSES (apk built + all three entries found).
2026-06-19 22:28:56 +03:00

34 lines
1.3 KiB
Plaintext

// Android `.apk` bundle smoke test — the corpus's first Android bundler
// coverage.
//
// `sx build --target android --apk <out.apk> --bundle-id <id> -o <lib.so>`
// cross-compiles for aarch64-linux-android and runs the sx default_pipeline
// → bundle_main, which drives javac/d8/aapt2/zipalign/apksigner to produce a
// signed APK containing `AndroidManifest.xml`, `classes.dex`,
// `lib/arm64-v8a/<lib.so>`, and `META-INF/` signatures. The `.build` `apk`
// directive builds + inspects the zip entries, then cleans up.
//
// GATED on the Android SDK (auto-discovered at $ANDROID_HOME /
// $ANDROID_SDK_ROOT / ~/Library/Android/sdk) + a real JDK on PATH — the macOS
// `/usr/bin/javac` stub is not enough. When either is missing the example
// SKIPS cleanly so a plain `zig build test` stays green.
//
// Build-only: `--target android` is a cross-compile, so the APK can't run on
// the build host. Runtime launch is validated manually on an emulator/device.
//
// Shape mirrors 1424 (a `#jni_main` Activity whose `onCreate` calls
// `super.onCreate(b)`, so the app is well-formed).
#import "modules/std.sx";
#import "modules/build.sx";
Bundle :: #jni_class("android/os/Bundle") extern { }
SxApp :: #jni_main #jni_class("co/swipelab/sxapksmoke/SxApp") {
onCreate :: (self: *Self, b: *Bundle) {
super.onCreate(b);
}
}
main :: () -> i32 { 0 }