How to sign an Android app, generated with Processing Android (or generated with another tool)?
Create a (Windows-) batch file (.bat) with the following code:
@echo off ECHO. set /p varSketchName="Please enter the Name of your sketch: " ECHO. set /p varSketchAlias="Please enter an Alias for your sketch: " ECHO. ECHO [KEYTOOL] keytool -genkey -v -keystore %~dp0%varSketchName%-release-key.keystore -alias %varSketchAlias% -keyalg RSA -keysize 2048 -validity 10000 pause ECHO [ANT RELEASE] call ant release pause ECHO [JARSIGNER] call jarsigner -verbose -keystore %~dp0%varSketchName%-release-key.keystore %~dp0bin\%varSketchName%-release-unsigned.apk %varSketchAlias% pause ECHO [JARSIGNER VERIFY] call jarsigner -verify %~dp0bin\%varSketchName%-release-unsigned.apk pause ECHO [ZIPALIGN] set /p varSignedAppName="Please enter name for final signed apk (w/o .apk extension): " call zipalign -v 4 %~dp0bin\%varSketchName%-release-unsigned.apk %~dp0%varSignedAppName%.apk
Programs you need:
- keytool.exe (part of the Java JDK)
- ant.bat (part of Apache ant)
- jarsigner.exe (part of the Java JDK)
- zipalign.exe (part of the Android SDK)
Steps:
- In Processing: create your sketch in Android Mode
- Export the sketch as an Android Project (Ctrl-Shift-E)
- Copy the .bat-file above to the newly created android directory and run it
- Name of your sketch = name of the .pde-file (without .pde!)
- Alias = same as the name (or something else)
- Enter a password for your keystore
- Enter your personal data
- Enter the same keystore password again
- Enter the name of the final .apk-file (without the .apk extension!)
N.B. Make sure your folder names DON’T include any SPACES! That will break the batch file.
And there you go! You’ve got a signed .apk file!