Using Cordova 8.1.2 with Visual Studio

Here you’ll find some references to setup your environment for Cordova CLI 8.1.2 apps development with (optionally) Microsoft Visual Studio 2015 / 2017. This guide is focused on the Android platform, but it’s mostly valid for iOS apps as well.

Visual Studio Cordova Logo

Install NodeJS 6.x

To ensure build and plugins compatibility, proceed to install NodeJS 6.x first. Please note that installing a version newer (or older) than 6.x could result in several build errors.

Open a command prompt and run npm cache clean when done.

Install Gradle 4.10.x

To ensure plugins compatibility, proceed to install Gradle 4.10.x with the linked instructions. You may or may not install a newer version at your own risk.

Upgrade your global Cordova CLI version

To upgrade to Cordova CLI 8.1.2, open a command prompt and type:

npm install -g [email protected]

Wait for this process to end and continue with the steps below to proceed upgrading your app(s) individually.

Why not use Cordova 9.x instead? Please read this article to check the reasons for using an older CLI version with Visual Studio, fixing the missing Deploy to Emulator option in VS 2017, and how to change the target Android API from Visual Studio.

Quick version check

Before continuing, make sure you have versions similar to the ones shown below:

Cordova, Node, Gradle versions for Cordova 8.1.2

Cordova, Node, Gradle versions for Cordova 8.1.2

Select the globally installed version from config.xml

Open the designer view for config.xml and select your globally installed Cordova version. If the globally installed version is not found, type the desired version number directly and it will be downloaded and stored locally for the current app only.

visual studio cordova toolset

VS2017 cordova toolset

Upgrade the cordova-android version from your app

If you plan to migrate your exising app created with an older cordova or cordova-android version, please follow this guide on how to properly update your android/ios platform.

Fixing cordova platform add android-related errors

Make sure you have installed the Node 6.x and Gradle 4.10.x versions as shown earlier. Newer/older versions could introduce incompatibilities. Also, make sure to carefully follow the steps previously provided, and you’ll manage to start building Cordova apps in no time.

Prevent error: edge is not precompiled for Node (…)

Install edge-js from the command line in the project’s folder:

npm install edge-js

Prevent error DEP10402: Could not locate a deployable apk

This error was introduced to Visual Studio by the folder structure change from [email protected] To fix this, create a settings file platforms/android/build-extras.gradle with these contents or download it here.

android.applicationVariants.all { variant ->
	variant.outputs.all { output ->
		if (output.outputFile != null &&'.apk')) {
			/* Fix Visual Studio 2015 / 2017 [email protected]+ Error DEP10402: Rename and move APK one level up */
			println ">>> Renaming APK for Visual Studio [from]"
			output.outputFileName = "../../../../../build/outputs/apk/android-${}.apk"

The generated APK files now will be android-debug.apk or android-release.apk, and will be present in the platforms/android/build/outputs/apk folder where Visual Studio expects to find it.

Rename the output APK to add package name + version

To change the output APK file name from the generic android-debug.apk to something like, add this to the platforms/android/build-extras.gradle file, or download it here.

android.applicationVariants.all { variant ->
	variant.outputs.all { output ->
		if (output.outputFile != null &&'.apk')) {
			/* Add package name and version info to generated APK */
			println ">>> Renaming APK to add version [from]"
			output.outputFileName = "${variant.applicationId}-${}-${variant.versionName}.apk"

WARNING: If you rename the APK as shown here, Visual Studio won’t locate the file anymore and Deploy to Device / Emulator will stop working.

Android API levels supported by cordova-android

The supported Android API Levels and Android Versions for the past few cordova-android releases can be found in the following table. Taken from Cordova’s Requirements and Support page.

Cordova Android API levels supported

Cordova Android API levels supported