Reputation: 301
How do I compile my apps with my developer certificate keys when using cordova from the command line?
By default it uses a debug certificate key, how do I use the one that I use when i'm building using the online phonegap build tool?
Upvotes: 0
Views: 4146
Reputation: 5352
Remove the console plugin:
D:\projects\Phonegap\Example> cordova plugin rm org.apache.cordova.console
To generate a release build for Android, we first need to make a small change to the AndroidManifest.xml file found in platforms/android.
Edit the file and change "android:debuggable" to "false".
Now we can tell Cordova to generate our release build:
D:\projects\Phonegap\Example> cordova build --release android
Then, we can find our unsigned APK file in platforms/android/ant-build. In our example, the file was platforms/android/ant-build/Example-release-unsigned.apk
.
Note: you want to create key, please proceed with the following steps.
Key Generation Syntax:
keytool -genkey -v -keystore .keystore -alias -keyalg -keysize -validity
Examples:
keytool -genkey -v -keystore NAME-mobileapps.keystore -alias NAMEmobileapps -keyalg RSA -keysize 2048 -validity 10000
keystore password? : xxxxxxx
What is your first and last name? : xxxxxx
What is the name of your organizational unit? : xxxxxxxx
What is the name of your organization? : xxxxxxxxx
What is the name of your City or Locality? : xxxxxxx
What is the name of your State or Province? : xxxxx
What is the two-letter country code for this unit? : xx
Then the Key store has been generated with name as NAME-mobileapps.keystore
Place the generated keystore in D:\projects\Phonegap\Example\platforms\android\ant-build
To sign the unsigned APK, run the jarsigner tool which is also included in the JDK:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore
Example:
D:\projects\Phonegap\Example\platforms\android\ant-build> jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore NAME-mobileapps.keystore Example-release-unsigned.apk xxxxxmobileapps
Enter KeyPhrase as 'xxxxxxxx'
This signs the apk in place.
Finally, we need to run the zip align tool to optimize the APK. Run either of the following:
D:\projects\Phonegap\Example\platforms\android\ant-build> zipalign -v 4 Example-release-unsigned.apk Example.apk
D:\projects\Phonegap\Example\platforms\android\ant-build> C:\Phonegap\adt-bundle-windows-x86_64-20140624\sdk\build-tools\android-4.4W\zipalign -v 4 Example-release-unsigned.apk Example.apk
Now we have our final release binary called example.apk and we can release this on the Google Play Store.
Upvotes: 3