A bash script to sign Android APK files with a self-generated keystore.
Make sure you have the following tools installed:
keytool(comes with Java JDK)jarsigner(comes with Java JDK)zipalign(comes with Android SDK Build Tools)apksigner(comes with Android SDK Build Tools)
./signing.sh <APK_NAME> <PASSWORD>APK_NAME: The name of the unsigned APK file you want to signPASSWORD: The password to use for the keystore (minimum 6 characters)
chmod 777 signing.sh
./signing.sh example.apk testtest- Validates Input: Checks if the APK file exists and parameters are provided
- Cleans Up: Removes any previous signing files
- Generates Keystore: Creates a new keystore with RSA 2048-bit key
- Signs APK: Signs the APK using jarsigner
- Aligns APK: Optimizes the APK with zipalign for better performance
- Signs with apksigner: Applies final signature
- Verifies: Confirms the APK is properly signed and aligned
The script will generate:
signed_<APK_NAME>.apk- Your signed APK fileandroid-app-hack-<APK_NAME>.keystore- The generated keystoresigned_<APK_NAME>.apk.idsig- Signature file
The script will exit with an error message if:
- Parameters are missing
- APK file doesn't exist
- Any step in the signing process fails
Free to use and modify.