Search code examples
javaphonegap-buildandroid-install-apkjarsignerzipalign

How to Sign apk programmatically in java / by using command line


I am working on phonegap project. I have one apk file which is working fine and installing properly on android device, but I want to do some modification in that apk file, for that what i am doing is, just renaming it's extention from apk to zip and simply extracting it, and doing some changes in HTML file which is located at asset/www folder. And after modifying all necessary changes again compressing that folder back to zip and again back to apk. I just want to install that modified apk file onto android device. But while installing it is parsing properly but getting error Apk not installed, I think I am getting this error because that modified apk is not signed and zipalign.

So my main question is, how can i signed my apk using jarsigner and zipalign mechanism is there any java code or command so that i can achieve this?


Solution

  • The answer was to follow the guide on https://developer.android.com/studio/publish/app-signing.html#signing-manually.