Update Cordova Android 5 – a quick guide

If you received the “Google Play warning: You are using a vulnerable version of Apache Cordova” email some days ago, you have two months to update your Cordova Android platform; do it, unless you want to see your favorite app kicked out of Play Store.

Since Cordova 3.6 a lot of things changed: the plugin archive, the build system, the keystore etc.

This quick guide covers these steps:

  1. Android SDK update
  2. Cordova update
  3. Cordova Android update
  4. Plugins update
  5. Keystore update (optional)
  6. Final checks

1) Android SDK update

Open the Android SDK Manager. If you can’t locate the  Android 6.0 (API 23) folder, download and install the latest release of Android SDK Manager.

Open the Android 6.0 (API 23) folder and install the “SDK Platform”.

Open the Tools folder and update “Android SDK Tools”, “Android SDK Platform-tools” and “Android SDK Build-tools.

2) Cordova update

Run this command:

sudo npm install -g cordova

3) Cordova Android update

Run this command:

cordova platform update android

Check the new Cordova Android version:

cordova platform

4) Plugins update

The cordovapluginwhitelist plugin is now required.

Run this command:

cordova plugin add cordova-plugin-whitelist

Add the whitelist relevant tags (access, allow-navigation, allow-intent) to your config.xml file (more info here), according to your backend configuration.

Also, remember to add  the Content-Security-Policy meta tag to your html files (or just to the index.html file, if it’s a Single Page App), according to your backend configuration.

Then, check all the active plugins for updates. It’s likely that they have changed name or repository in the meantime. For example to update the Social Sharing plugin run these commands:

cordova plugin remove https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
cordova plugin add cordova-plugin-x-socialsharing

5) Keystore update (optional)

If you used to sign your builds automatically via the ant.properties file, you’re required to create a new file in the same folder (platforms/android). Call it release-signing.properties and put there the old keystore info. For example, JKS keystore info looks like this:

storeFile=../../../android_keys/YOURKEYSTORE.keystore
storeType=jks
keyAlias=YOURALIAS

Good news: you can now use relative paths for the storeFile field.

Optionally, you can store the passwords in the same file, adding two more lines like these:

storePassword=YOURPASSWORD
keyPassword=YOURPASSWORD

6) Final checks

Now, you should be ready to build your Cordova Android app. If something goes wrong, continue reading!

Check that your project.properties and CordovaLib/project.properties files have the right target:

# Project target
target=android-23

Check that your AndroidManifest.xml file reflects the Android SDK you just installed.

Check that you have all the required NPM packages to compile. If you experience compile errors like Cannot find module ‘bplist-parser’, install (or perform a clean install by removing them first) the required modules, like this:

npm install -g bplist-parser

Now you should met all the requirements to complete an Android build. If you experience errors during the build process, read it carefully and look for help online.

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *