I was doing some Android project using phonegap where I was asked to release the signed APK using command line without any user input. I use ‘ant’ utility to create the signed APK. But ‘ant’ expects the key settings should be available before doing the release.
‘keytool’ is one such tool to create keys and that key can be used for ‘ant’ to create the APK.
keytool -genkey -noprompt -keystore mykeystore -storepass mystorepass -alias myfirstkey -keypass firstpass -dname “CN=net.jeema.sms, OU=web, O=JEEMA, L=Tirunelveli, S=Tamilnadu, C=IN” -validity 10000
You need to navigate to the android project folder and execute the above command. This command will create a file ‘mykeystore’ in the directory and create the key ‘myfirstkey’ along with the password inside the file.
Basically for the first time it will create a keystore called ‘mykeystore’ with the password ‘mystorepass’. When want to create the second key then the same keystore can be used.
Once the key is created input the key details in the local.properties which is available in the android project folder as below and save it.
Now, the ‘ant release’ command will pick the above key details and able to create the signed APK. The APK will be available under the bin directory.