In correspondence with Cordova news version 5.0.0 is ready. I tried to upgrade all my Android projects like it was usually.
To update Cordova framework itself:
npm update -g cordova
To update library in Android project:
cordova platform update android
After building new version using "--release" option:
cordova build android --release
I got only unsigned version. Strange...
So how is it possible to reuse existing keystore (previously generated by keytool and used by Cordova 4.0.0) to get signed APK?
By using the --gradleArg flag in your Cordova build or run commands: By placing a file called gradle.properties in your Android platform folder ( <your-project>/platforms/android) and setting the properties in it like so: By extending build.gradle via a build-extras.gradle file and setting the property like so:
Now create a file name myproject.gradle in /home/username/.signing (create the folder if necessary). This file will contain your signing config, that should be used to sign the package. This could look like the following: For more information on the signing configuration for android read their documentation.
It looks like Cordova 5.0.0 uses Gradle build automation system instead of Ant. So original settings for keystore defined in the file "/platforms/android/ant.properties" will not be used during building. So we will get unsigned APK as a result.
The simplest and cleanest way to add an external configuration is through a separate Gradle file apply from: './keystore.gradle' android { signingConfigs { release { storeFile file (keystore.storeFile) storePassword keystore.storePassword keyAlias keystore.keyAlias keyPassword keystore.keyPassword } } }
It looks like Cordova 5.0.0 uses Gradle build automation system instead of Ant. So original settings for keystore defined in the file "/platforms/android/ant.properties" will not be used during building. So we will get unsigned APK as a result.
To solve this issue we need to tell Gradle to use existing keystore as well. Investigation of build.gradle gives us useful information that we need to provide signingConfigs.
But it is bad idea to do that in this file because it is labelled as auto-generated and it should be free of any editing.
So finally I have found the way to solve it. Object "signingConfigs" will be constructed from file with filename stored in cdvReleaseSigningPropertiesFile. In correspondence with documentation the default value of this variable is "release-signing.properties". So we need just to create new file with such name in the same folder as "build.gradle" file and put inside the following content:
storeFile=..\\..\\some-keystore.keystore storeType=jks keyAlias=some-key // if you don't want to enter the password at every build, you can store it with this keyPassword=your-key-password storePassword=your-store-password
Path in example is specified for keystore saved in the project root directory. It has Windows style... In case of Linux you will need to use single slashes (not double backslashes like in above example).
In addition you can set your own path for signing settings file. To read more about that check the edge version of cordova documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With