Cordova/Android Gradle error: Failed to notify project evaluation listener

I’ve come across an issue with the default configuration for the android platform that’s preventing me from running my app without having to manually tweak build.gradle inside platforms/android. I already posted a bug report with details (without realizing this isn’t a bug so much as a support issue), so to save time I’ll just copy-pasta the Markdown below.

Essentially, is there something I have configured incorrectly so that build.gradle is auto-generated with the wrong Android Gradle plugin version? It’d be nice if everything would “just work” after ionic cordova platform add android, without me having to edit something manually.

Ionic version:


Current behavior:

When attempting to run a new app on Android (using ionic cordova run android, where the android platform has not already been added), the cordova.cmd build android step fails with this error (snippet of relevant logs follow):

> cordova.cmd build android --device
[cordova] FAILURE: Build failed with an exception.
[cordova] * What went wrong:
[cordova] A problem occurred configuring project ':app'.
[cordova] > Failed to notify project evaluation listener.
[cordova]    > org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;
[cordova] * Try:
[cordova] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[cordova] * Get more help at
[cordova] BUILD FAILED in 7s

Expected behavior:

This error should not occur; the project should build and run successfully instead.

Steps to reproduce:

  1. Start a new Ionic app (ionic start bug-demo blank --type=angular --cordova)
  2. Build & run on a device/emulator (ionic cordova run android)
  3. The previous command should fail with the error listed above.

Related code:

N/A; simply the code generated by ionic start is enough to reproduce the bug.

Other information:

I have followed this StackOverflow answer before to solve the problem. Going off that post, it seems the only issue is the Android Gradle plugin version being incompatible with my Gradle version. Making the following change in platforms/android/build.gradle will fix the problem for me:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {

    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

-        classpath ''
+        classpath ''

I replaced the auto-generated version with v4.0.0 by referencing the table on the Android Gradle Plugin release notes page (also linked in the SO answer above), since the Gradle version in platforms/android/gradle/wrapper/ is v6.2.2.

The issue may simply be that the auto-generated plugin version is incompatible with the auto-generated Gradle version.

Output of platforms\android\gradlew -v, if it’s helpful:

Gradle 6.2.2

Build time:   2020-03-04 08:49:31 UTC
Revision:     7d0bf6dcb46c143bcc3b7a0fa40a8e5ca28e5856

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_251 (Oracle Corporation 25.251-b08)
OS:           Windows 10 10.0 amd64

As I wrote this issue, I realized this may not be a problem with Ionic, but Cordova. :grimacing: Ask me and I’ll move the issue to their world if it’s irrelevant in this repo.

Ionic info:


   Ionic CLI                     : 6.10.1
   Ionic Framework               : @ionic/angular 5.2.2
   @angular-devkit/build-angular : 0.901.9
   @angular-devkit/schematics    : 9.1.9
   @angular/cli                  : 9.1.9
   @ionic/angular-toolkit        : 2.2.0


   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 4 other plugins)


   cordova-res (update available: 0.15.1) : 0.14.0
   native-run                             : 1.0.0


   Android SDK Tools : 26.1.1
   NodeJS            : v12.14.1
   npm               : 6.13.4
   OS                : Windows 10