Android APK hardening and re-signing

Use Tencent cloud to harden, download and sign again. The apK after successful signature can be parsed and installed on Huawei Hongmon and Android8, but fails to be parsed and installed on Android11

A problem occurred while parsing the software package

The solution

Align them using the Zipalign tool and re-sign them using ApkSigner

Zipalign and Apksigner are both officially provided by Google and installed when installing the Android environment. Environment variables need to be configured before using them. Zipalign and Apksigner are available in the Android SDK/build-tools/SDK version/directory

Control Panel – System and Security – System – Advanced System Settings – Advanced – Environment Variables – System variable PATH

zipalignTool alignment

Execute commands in the keystore and apk directories

Alignment commands

Zipalign-p-f-v 4 Unaligned (Jarsigner signed)APK file Generated APK fileCopy the code
zipalign -p -f -v 4 .\myapp1.apk .\myapp2.apk
Copy the code

Verify the alignment

Zipalign-c-v 4 APK file to verifyCopy the code

The apK installation package is invalid or incompatible when it is installed directly

apksignerThe signature again

Apksigner sign -- KS key store file --ks-key-alias Key store alias --ks-pass pass: password --v2-signing-enabled true -v --out Indicates the APK file after the signature APK file to sign (after alignment)Copy the code

personal

apksigner sign --ks .\my-release-key.keystore --ks-key-alias my-key-alias --ks-pass pass:123456. --v2-signing-enabled true -v --out .\myapp3.apk .\myapp2.apk
Copy the code

A Signed message is displayed indicating that the signature is successful, and the hardened APK can be installed normally.

If you like it, just give it a thumbs up and go ^-^