Utilities

Check APK ZIP entry alignment

Check stored APK entry offsets and save the native alignment report.

Agent

overview

What zipalign-check does

Supply an APK FILE. The adapter runs source-built AOSP zipalign with fixed -c -P 16 -v 4 options and saves the native verification report on success. It checks alignment without rewriting the archive.

The check uses four-byte alignment for ordinary stored entries and 16 KiB alignment for stored .so entries. ZIP entry alignment does not establish ELF load-segment alignment, signature integrity or compatibility with a particular device. Compressed entries are not a substitute for an aligned stored native library.

The APK must be a nonempty local file of at most 20 MiB, with at most 5,000 ZIP entries, at most 20 MiB declared size per entry and at most 64 MiB declared total expansion. It must contain AndroidManifest.xml. The native subprocess has a 60-second timeout. Native output/logs and the combined report are checked against 4 MiB after execution; these are not peak memory or disk limits.

source hub.docker.com/r/nenadzaric/skills-android-zipalign-check

use cases

Where zipalign-check fits

Record alignment of an owned APK

Save the native entry-offset report with a file artifact. The owned fixture reports AndroidManifest.xml at offset 56 and a stored libowned.so at offset 16384, followed by Verification successful.

Catch a library that is only four-byte aligned

The four-byte-only fixture stores the same library bytes at offset 164. That offset is divisible by four but fails the fixed 16 KiB native-library check.

Keep alignment checking separate from rewriting

Use the check as a file-processing gate. It exposes no archive realignment, signing key, device connection or installation operation.

reference

zipalign-check inputs and flags

1 inputs
NameTypeFlagDescription
apkFILE--apkLocal APK ZIP within the 20 MiB file and declared ZIP bounds.

Showing key inputs. zipalign-check exposes 1 inputs in total.

example

Run zipalign-check

zipalign-check · command
zipalign-check --apk owned.apk -o alignment.txt
sample output
Verifying alignment of /hive/out/zipaligncheck-ltvxf1qy/input.apk (4)...
      56 AndroidManifest.xml (OK)
   16384 lib/arm64-v8a/libowned.so (OK)
Verification successful

guidance

Choosing zipalign-check

Choose this node to check APK ZIP entry offsets against fixed alignment settings. Use apksigner-verify separately for APK signature integrity; neither report establishes ELF segment alignment or device compatibility.

apksigner-verify

Check cryptographic signature integrity and signer fingerprints instead of ZIP alignment.

apkeditor-info

Extract APK metadata as JSON rather than verify ZIP entry alignment.

faq

zipalign-check questions

No. This node checks ZIP entry offsets, including 16 KiB alignment for stored .so entries. It does not inspect ELF load segments, run an app or establish compatibility with any device.

No. It copies the validated input into a task-local file and invokes only the native check operation. There is no rewriting, signing-key or device port.

The native-library setting is fixed at 16 KiB. The owned four-byte-only fixture places the stored library at offset 164: divisible by four, but not by 16384. The native check fails and the adapter exits 2.

The APK must be a nonempty local file of at most 20 MiB, with at most 5,000 ZIP entries, at most 20 MiB declared size per entry and at most 64 MiB declared total expansion. It must contain AndroidManifest.xml. The native subprocess has a 60-second timeout. Native output/logs and the combined report are checked against 4 MiB after execution; these are not peak memory or disk limits. Unsafe or duplicate member paths, encrypted entries and symlinks are rejected. A nonzero native exit becomes adapter exit 2; success requires the native Verification successful marker. Existing nonempty output is preserved.

The core is built from unmodified AOSP android-16.0.0_r1 source at platform/build commit 874fa586c48ae230ebfcff0df1b9c1b004fa8f7c with pinned Debian Android native dependencies and Clang. This is a source-built tool, not an official downloaded SDK binary or an SDK Build Tools version equivalence claim.

The final local image passed nine native cases, including worker-style filenames, aligned success, four-byte-only failure and output preservation. The same image passed a three-node platform run with downloaded fixture, native report and verifier checks of offsets 56 and 16384. Public image and source/notices downloads have been verified anonymously. The original tool ID is public in the Library.

The source link provides immutable ORAS retrieval directions and a bundle SHA-256 for the adapter/build files, pinned AOSP core source, original installed notices and matching Debian source packages for native dependencies. The AOSP core is Apache-2.0 with original component terms retained. No exhaustive composition or reproducible-build claim is made.

Run zipalign-check yourself

Actual native report downloaded from the owned aligned-fixture platform run. The temporary task path varies between runs; compare entry offsets and verification result rather than expecting identical report hashes across hosts.

Facts on this page come from the live Trickest tool library.