A Java-based utility for aligning and digitally signing (V1~V4 scheme compatible) Android APK files, featuring a Graphical User Interface (GUI), integrated zipalign functionality, and detailed signature verification output.
This project provides a convenient desktop application for the critical step of signing Android packages. It wraps the core functionality of the official Android apksigner library, enhances the process with an independent, custom-built zipalign implementation, and presents all operations through a user-friendly GUI built with the Standard Widget Toolkit (SWT).
The tool is designed to provide a comprehensive, multi-step process for preparing and signing APKs:
- Configuration: Load user arguments from the GUI into an
Argobject, including input file paths, keystore credentials, and signing scheme flags. - ZipAlign (Optional): If not skipped, the tool performs a
zipalignoperation on the APK using its custom implementation found inZipAlign.java. This ensures uncompressed data starts at specified byte boundaries (e.g., 4-byte, and optionally 16KiB for.sofiles) for efficient runtime resource loading. - Signing: The actual digital signing is performed by calling the official Android
ApkSignerToolvia its internal API (com.android.apksigner.ApkSignerTool), applying the selected signing schemes (V1, V2, V3, V4) and keystore configuration. - Verification: After signing, the integrity and signature are verified using a custom wrapper around
com.android.apksig.ApkVerifier, providing detailed verification results and extracted certificate information.
- GUI-Driven Workflow: Easy-to-use graphical interface built with SWT, eliminating the need for command-line arguments.
- Comprehensive Scheme Support: Enables signing using all major Android signing schemes: V1 (JAR signing), V2 (Full APK Signature Scheme v2), V3 (APK Signature Scheme v3, for key rotation), and V4 (APK Signature Scheme v4, for incremental file system).
- Built-in ZipAlign: Includes a native Java implementation of the
zipaligntool, which can align uncompressed entries to the specified boundaries (default 4 bytes) and optionally align.sofiles to a larger boundary (default 16KiB). - Flexible Keystore Management:
- Supports using a custom release keystore with alias, keystore password, and key password.
- Automatic discovery and handling of the default Android debug keystore.
- Detailed Verification: Provides structural output for verification, including per-scheme verification status, error/warning lists, and a summary of signer certificate details (Subject DN, Issuer DN, SHA-256 hashes, Expiry, Key Size).
- Hash Validation: Ability to check the resulting APK signature against a list of provided SHA-256 certificate hashes for security and compliance.
- Processing Flags: Options for "Verify Only," "Dry Run," "Overwrite Original File," and toggles for verbose or debug logging.
To use the tool, follow these steps in the graphical interface:
- Input and Output:
- Specify the target APK file or a folder containing APKs in the APK File/Folder field.
- Optionally specify an Output Directory for the signed/aligned files.
- Keystore Settings:
- Check Use Debug Keystore to automatically use a debug key, or uncheck it to use a Custom Keystore.
- For a Custom Keystore, provide the
File Path,Alias,Keystore Password, andKey Password.
- General Options (Signing Schemes):
- Select which Signing Schemes (V1, V2, V3, V4) should be applied during the signing process.
- General Options (Processing Flags):
- Configure flags like
Verify Only(skips signing),Skip ZipAlign,Overwrite Original File, andAllow Resign.
- Configure flags like
- Advanced Options:
- If using V3 signing for key rotation, specify the path to the Lineage File.
- Execute:
- Click the Start Execution button.
- The results, status, errors, and verification details will be streamed to the Console Output area.
The project relies on two main external libraries for its core functionality:
| Dependency | Purpose | Source File Reference |
|---|---|---|
Android apksigner Library |
Core digital signing and some verification logic (used internally). | SignTool.java, AndroidApkSignerVerify.java |
| Eclipse SWT (Standard Widget Toolkit) | Provides the cross-platform GUI framework. | ApkSignerGui.java |
The project is licensed under the Apache License, Version 2.0 (the "License"). See LICENSE for details.
