For cordova 5.1.1+, refer to Ronny Elflein r11lein answer https://stackoverflow.com/a/30980293/2163398
The current answer is good (by @maxim), but we want to keep platform-specific folder untouched, so we can maintain it out of version control. So I created this Hook to automatically copy the "release-signing.properties" file in android folder.
So, first, place your keystore in your project root. Then create the "release-signing.properties" in a the folder config, in the root of your cordova project. Contents (storeFile 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):
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
Then, add if not exists the "after_prepare" folder inside the "hooks" folder, and crete in it a file called "copy_assets.js".Contents:
#!/usr/bin/env node
// Files to be copied, with source and destination
var ncp = require('ncp').ncp,
transfers = [
{
'source': './config/android/release-signing.properties',
'destination': './platforms/android/release-signing.properties'
}
];
ncp.limit = 16;
transfers.forEach(function(transfer) {
ncp(transfer.source, transfer.destination, function (err) {
if (err) {
return console.error(err);
}
console.log('====== Assets moved from ' + transfer.source + ' to ' + transfer.destination + ' ======');
});
});
If you don't hace ncp in your project, open a command promt in the project folder root and run the command (it's posible you need to create a a packages.json file in your project root):
npm install ncp
Then, you can run:
cordova build android --release