Common Apache Cordova build errors with Android

This topic includes some of the common Cordova CLI 7.1.0 build errors that I’ve found, with the recommended solutions or the ones that worked for me. References to Visual Studio included.

Apache Cordova logo phonegap


Cannot find module ‘android-versions’

Run the following command in the project’s folder to add the required dependency:

npm install android-versions --save

Discussion about this error on this stackoverflow topic.

No such file or directory: cordova_plugins.js

This is an erratic error that happens whenever you have removed the cordova-android platform and added it back. Using the cordova prepare and cordova clean commands with successful results should recreate your files from the platforms/android/app folder and fix this error. As a last resort, you can remove and readd the cordova-android platform again.

Could not determine the dependencies of task ‘:lintVitalRelease’.

Project : declares a dependency from configuration ‘releaseCompile’ to configuration ‘release’ which is not declared in the descriptor for project :CordovaLib

Your gradle version is too high, possible solutions:

  • Return to a previous Gradle version
  • Upgrade to a newer Cordova version
  • Upgrade your cordova-android version

Error: edge is not precompiled for Node (…)

This error was introduced by Node 6.x. To solve this issue, install edge-js from the command line:

npm install edge-js

Clean the project and build normally.

Error DEP10402: Could not locate a deployable apk. You may need to build your project

This Visual Studio error was introduced 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"

Warning: Remember to recreate this file whenever you remove the android platform!

Execution failed for task ‘:transformClassesWithDexForRelease’

If you are using [email protected] or newer, you should uninstall the cordova-plugin-compat plugin because this cordova-android version already includes the and files provided by the plugin.

Use this command to force the removal of the obsolete compat plugin:

cordova plugin rm cordova-plugin-compat --force

Warning: Make sure the plugin was really removed; Visual Studio tends to keep plugin references in certain files like config.xml, android.json or fetch.json after removing the plugin from the IDE, and then re-adds the erased plugin on next build.

If required by another plugin (such as cordova-plugin-camera or cordova-plugin-geolocation) update those plugins to latest versions, then the depenency should be gone.

If you must keep another plugin that persists in the cordova-plugin-compat dependency, install cordova-plugin-compat version 1.2 from the command line:

cordova plugin add [email protected]

Then Clean Solution from the Build menu. If the problem persists, delete the platforms/android folder and build again to re-create it.

The cordova-plugin-compat 1.2 won’t be actually installed if you have cordova-android 6.3.0+, but the reference in config.xml will be added:

<plugin name="cordova-plugin-compat" spec="^1.2.0" />

Notice: When using [email protected], the following messages will show up in Visual Studio’s Error List on build time, since the plugin is not actually installed but skipped:

Error List

Visual Studio Error List

Discussion about this error on this stackoverflow topic.

Duplicate entry: android/support/v13/ …

Program type already present: …

This error is be introduced by the inclusion of different API levels for the library in your project properties or gradle file. To prevent this, edit and make sure all entries use the same API level, for example:

Where X is any library number.

Clean the project and rebuild the APK to fix this error. Check out this post for additional notes.

Failed to notify project evaluation listener;)V

Solution 1: Change the Android Gradle Plugin version

Open the platforms/android/build.gradle file from your project and change the  version to one that is compatible with your gradle version:

dependencies {
    classpath ''

The following table shows the required gradle version according to the Android gradle plugin version. For more info view the Android Gradle Plugin release notes.

Android gradle plugin versions

Android gradle plugin versions

For Cordova 7.1.0 and [email protected] with gradle 4.1, you can use version 2.3.3.

Solution 2: Clear gradle cache

Stop all running gradle instances:

gradle --stop

Delete the gradle cache folder:

  • On Windows: %USER_HOME%\.gradle\caches\
  • On MacOS: $HOME/.gradle/caches/

Discussion about this error on this stackoverflow topic.

cordovaProject.projectConfig.getFileResources is not a function

When using Visual Studio, this error is caused by selecting an old (6.x) Cordova version from the confix.xml designer. Select Globally Installed Cordova version, then clean the project from the Build menu or the command line.

NDK is missing a “platforms” directory

This issue was introduced by the Android tools gradle plugin 2.3.0.

Solution 1

To fix this, open the platforms/android/build.gradle file from your project and change the  version with the non-bugged 2.2.3 one:

dependencies {
    classpath ''

Solution 2

Installing the NDK would solve this warning as well, however this seems to require Android Studio, which is irrelevant for Cordova apps.

Discussion about this error on this stackoverflow topic.

The value of attribute “name” associated with an element type “item” must not contain the ‘<‘ character

To fix this error edit the api-versions.xml file in android-sdk\platform-tools\api and escape the “>” character properly. Find all occurrences of:

<method name="&lt;init>()V"/>

Replace with:

<method name="&lt;init&gt;()V"/>

Notice: You must clean your cordova project afterwards for this error to disappear.

Discussion about this error on the Google issue tracker.

You have not accepted the license agreements of the following SDK components: Android SDK Build-Tools 26.0.2

Install or reinstall the required Android SDK Build-tools from the Android SDK Manager or the Android Studio SDK manager.

Android SDK Manager

Android SDK Manager

HTTPS connections rejected in Release configuration

Whenever your app tries to connect to an HTTPS URL with an invalid SSL certificate, or a certificate that requires latest Webview to be considered valid, the connection will be rejected with HTTP code 0. While the recommended solution is to buy a quality SSL certificate or use the free one from Let’s Encrypt, there’s a workaround to force your app to ignore invalid certificates.

Note: This fix was applied in [email protected]

Locate and edit, then edit the onReceivedSslError  method as shown in the following UPPERCASE comments:

public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

	final String packageName = parentEngine.cordova.getActivity().getPackageName();
	final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

	ApplicationInfo appInfo;
	try {
		appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
		if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
			// debug = true
		} else {
			// debug = false
			//super.onReceivedSslError(view, handler, error);
	} catch (NameNotFoundException e) {
		// When it doubt, lock it out!
		super.onReceivedSslError(view, handler, error);

Now SSL certificate errors will be ignored in both Debug and Release configurations.

How to debug your Cordova Android app