Common Apache Cordova build errors with Android

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

Cannot find module ‘android-versions’

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

Discussion about this error on this stackoverflow topic.

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 DEP10402: Could not locate a deployable apk. You may need to build your project

This error was introduced into Visual Studio with newer gradle versions with the creation of a new folder in the APK output path. To revert this change, create a settings file platforms/android/build-extras.gradle with these contents:

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

Execution failed for task ‘:transformClassesWithDexForRelease’

If you are using cordova-android@6.3.0 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:

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:

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:

Notice: When using cordova-plugin-compat@1.2, 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.

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:

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 cordova-android@6.3.0 with gradle 4.1, you can use version 2.3.3.

Solution 2: Clear gradle cache

Stop all running gradle instances:

Delete the gradle cache folder:

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

Discussion about this error on this stackoverflow topic.

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:

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:

Replace with:

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 cordova-android@6.3.0.

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

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

Having another Cordova build-related issue?

You may leave your comment below with your error description and we’ll try to find a solution. Please include your cordova and cordova-android versions, and if using Visual Studio, mention which version do you have.

All product names, logos, and brands in this website are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.