Ionic cordova run android is failing

Hello,

i am trying to run ionic cordova run android but i always fails. here is the exception details:
image

here is the ionic info details:

please help.

Thanks

1 Like

what is your installed gradle version?

here is the gradle version details:


Gradle 4.10

Build time: 2018-08-27 18:35:06 UTC
Revision: ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL: 1.0-rc-3
Kotlin: 1.2.60
Groovy: 2.4.15
Ant: Apache Ant™ version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Windows 10 10.0 amd64

Thanks.

Sorry for the late reply, as my account was on hold.

Your Cordova tooling seems to be out of date - current cordova-android is 7.1.1 - which might be causing all kinds of problems. You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

Also, your error message indicates a problem reading some JSON file. Does that ring a bell?

Thanks for your reply. i have updated the android platform but still getting the same json exception. not able to figure out which json file it is.

this is my build.gradle under cordovaLib folder:


ext {
    apply from: 'cordova.gradle'
    cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}

**apply plugin: 'com.android.library'**
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = 'org.apache.cordova'
version = '7.1.1'

android {
    compileSdkVersion cdvCompileSdkVersion
    buildToolsVersion cdvBuildToolsVersion
    publishNonDefault true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
    }
}

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                name 'Cordova'
                url 'https://cordova.apache.org'
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'stevengill'
                        name 'Steve Gill'
                    }
                }
                scm {
                    connection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    developerConnection 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
                    url 'https://git-wip-us.apache.org/repos/asf?p=cordova-android'

                }
            }
        }
    }
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

artifacts {
    archives sourcesJar
}

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    configurations = ['archives']
    pkg {
        repo = 'maven'
        name = 'cordova-android'
        userOrg = 'cordova'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://git-wip-us.apache.org/repos/asf?p=cordova-android.git'
        websiteUrl = 'https://cordova.apache.org'
        issueTrackerUrl = 'https://issues.apache.org/jira/browse/CB'
        publicDownloadNumbers = true
        licenses = ['Apache-2.0']
        labels = ['android', 'cordova', 'phonegap']
        version {
            name = '7.1.1'
            released  = new Date()
            vcsTag = '7.1.1'
        }
    }
}

bold line is line number 40 which is indicated in the exception. also i have attached my android.json under Platforms>Android folder.

{
  "prepare_queue": {
    "installed": [],
    "uninstalled": []
  },
  "config_munge": {
    "files": {
      "res/xml/config.xml": {
        "parents": {
          "/*": [
            {
              "xml": "<feature name=\"Camera\"><param name=\"android-package\" value=\"org.apache.cordova.camera.CameraLauncher\" /></feature>",
              "count": 1
            },
            {
              "xml": "<feature name=\"Device\"><param name=\"android-package\" value=\"org.apache.cordova.device.Device\" /></feature>",
              "count": 1
            },
            {
              "xml": "<feature name=\"SplashScreen\"><param name=\"android-package\" value=\"org.apache.cordova.splashscreen.SplashScreen\" /><param name=\"onload\" value=\"true\" /></feature>",
              "count": 1
            },
            {
              "xml": "<feature name=\"Whitelist\"><param name=\"android-package\" value=\"org.apache.cordova.whitelist.WhitelistPlugin\" /><param name=\"onload\" value=\"true\" /></feature>",
              "count": 1
            }
          ]
        }
      },
      "AndroidManifest.xml": {
        "parents": {
          "/*": [
            {
              "xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
              "count": 1
            }
          ],
          "application": [
            {
              "xml": "<provider android:authorities=\"${applicationId}.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"org.apache.cordova.camera.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/camera_provider_paths\" /></provider>",
              "count": 1
            }
          ]
        }
      },
      "config.xml": {
        "parents": {
          "/*": [
            {
              "xml": "<feature name=\"Keyboard\"><param name=\"android-package\" onload=\"true\" value=\"io.ionic.keyboard.IonicKeyboard\" /></feature>",
              "count": 1
            },
            {
              "xml": "<allow-navigation href=\"http://localhost:8080/*\" />",
              "count": 1
            },
            {
              "xml": "<preference name=\"webView\" value=\"com.ionicframework.cordova.webview.IonicWebViewEngine\" />",
              "count": 1
            },
            {
              "xml": "<feature name=\"IonicWebView\"><param name=\"android-package\" value=\"com.ionicframework.cordova.webview.IonicWebView\" /></feature>",
              "count": 1
            }
          ]
        }
      }
    }
  },
  "installed_plugins": {
    "cordova-plugin-camera": {
      "PACKAGE_NAME": "io.ionic.starter"
    },
    "cordova-plugin-device": {
      "PACKAGE_NAME": "io.ionic.starter"
    },
    "cordova-plugin-ionic-keyboard": {
      "PACKAGE_NAME": "io.ionic.starter"
    },
    "cordova-plugin-ionic-webview": {
      "PACKAGE_NAME": "io.ionic.starter"
    },
    "cordova-plugin-splashscreen": {
      "PACKAGE_NAME": "io.ionic.starter"
    },
    "cordova-plugin-whitelist": {
      "PACKAGE_NAME": "io.ionic.starter"
    }
  },
  "dependent_plugins": {},
  "modules": [
    {
      "id": "cordova-plugin-camera.Camera",
      "file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
      "pluginId": "cordova-plugin-camera",
      "clobbers": [
        "Camera"
      ]
    },
    {
      "id": "cordova-plugin-camera.CameraPopoverOptions",
      "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",
      "pluginId": "cordova-plugin-camera",
      "clobbers": [
        "CameraPopoverOptions"
      ]
    },
    {
      "id": "cordova-plugin-camera.camera",
      "file": "plugins/cordova-plugin-camera/www/Camera.js",
      "pluginId": "cordova-plugin-camera",
      "clobbers": [
        "navigator.camera"
      ]
    },
    {
      "id": "cordova-plugin-camera.CameraPopoverHandle",
      "file": "plugins/cordova-plugin-camera/www/CameraPopoverHandle.js",
      "pluginId": "cordova-plugin-camera",
      "clobbers": [
        "CameraPopoverHandle"
      ]
    },
    {
      "id": "cordova-plugin-device.device",
      "file": "plugins/cordova-plugin-device/www/device.js",
      "pluginId": "cordova-plugin-device",
      "clobbers": [
        "device"
      ]
    },
    {
      "id": "cordova-plugin-ionic-keyboard.keyboard",
      "file": "plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js",
      "pluginId": "cordova-plugin-ionic-keyboard",
      "clobbers": [
        "window.Keyboard"
      ]
    },
    {
      "id": "cordova-plugin-ionic-webview.IonicWebView",
      "file": "plugins/cordova-plugin-ionic-webview/src/www/util.js",
      "pluginId": "cordova-plugin-ionic-webview",
      "clobbers": [
        "Ionic.WebView"
      ]
    },
    {
      "id": "cordova-plugin-splashscreen.SplashScreen",
      "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",
      "pluginId": "cordova-plugin-splashscreen",
      "clobbers": [
        "navigator.splashscreen"
      ]
    }
  ],
  "plugin_metadata": {
    "cordova-plugin-camera": "4.0.3",
    "cordova-plugin-device": "2.0.2",
    "cordova-plugin-ionic-keyboard": "2.1.2",
    "cordova-plugin-ionic-webview": "2.1.0",
    "cordova-plugin-splashscreen": "5.0.2",
    "cordova-plugin-whitelist": "1.3.3"
  }
}

Please suggest.

Thanks&Regards.

Post your ionic info again please.

Create a new project with ionic start, update it to most recent versions, then try to build that one. Does it work?

here is the ionic info:

will let you know if build works with new project.

Thanks & Regards

1 Like

Hello Sir,

I am facing the same exception with my new app as well. here i have created a brand new app with ionic start and added latest android platform(7.1.1).

 cordova run android
Android Studio project detected
ANDROID_HOME=C:\Users\TECHLAP31\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
:wrapper

BUILD SUCCESSFUL in 15s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\CordovaLib\build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> com/google/gson/JsonParseException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 34s
(node:7636) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\CordovaLib\build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> com/google/gson/JsonParseException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 34s
    at ChildProcess.whenDone (C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>

Please suggest.

Thanks & Regards

That’s really strange.

Is this the complete output of the command? What command exactly?
Run the same command with --verbose added at the end and post its output.

Hello Sir,

the command i tried is ionic cordova run android

here is the complete output with --verbose switch:

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>ionic cordova run android --verbose
  ionic:cli-utils Terminal info: { tty: true, ci: false } +0ms
  ionic:cli-utils CLI global options: { _: [ 'cordova', 'run', 'android' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +3ms
  ionic:cli-utils:lib:project Project type from config: Ionic Angular 3 (ionic-angular) +0ms
  ionic:cli-utils Project name: undefined +253ms
  ionic:cli Context: { binPath: 'C:\\Users\\TECHLAP31\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: 'C:\\Users\\TECHLAP31\\AppData\\Roaming\\npm\\node_modules\\ionic', execPath: 'C:\\My Drive\\Demo\\Mobile App\\IonicApps\\TestApp2', version: '4.1.1' } +0ms
  ionic:cli-utils:lib:integrations:cordova:config Using config.xml: C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\config.xml +0ms
  ionic:cli-utils:lib:hooks Looking for ionic:build:before npm script. +0ms
  ionic:cli-utils:lib:project:ionic-angular:build Looking for ionic:build npm script. +0ms
> ionic-app-scripts build --target cordova --platform android
[16:20:09]  ionic-app-scripts 3.2.0
[16:20:09]  build dev started ...
[16:20:09]  clean started ...
[16:20:09]  clean finished in 50 ms
[16:20:09]  copy started ...
[16:20:09]  deeplinks started ...
[16:20:09]  deeplinks finished in 15 ms
[16:20:09]  transpile started ...
[16:20:14]  transpile finished in 4.31 s
[16:20:14]  preprocess started ...
[16:20:14]  preprocess finished in 1 ms
[16:20:14]  webpack started ...
[16:20:14]  copy finished in 4.48 s
[16:20:17]  webpack finished in 3.46 s
[16:20:17]  sass started ...
[16:20:18]  sass finished in 1.20 s
[16:20:18]  postprocess started ...
[16:20:18]  postprocess finished in 13 ms
[16:20:18]  lint started ...
[16:20:18]  build dev finished in 9.18 s
[16:20:21]  lint finished in 2.58 s
  ionic:cli-utils:lib:hooks Looking for ionic:build:after npm script. +14s
> cordova run android --verbose
No scripts found for hook "before_run".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Android Studio project detected
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\app\src\main\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www
  copy  www\assets\fonts\ionicons.eot platforms\android\app\src\main\assets\www\assets\fonts\ionicons.eot (updated file)
  copy  www\assets\fonts\ionicons.scss platforms\android\app\src\main\assets\www\assets\fonts\ionicons.scss (updated file)
  copy  www\assets\fonts\ionicons.svg platforms\android\app\src\main\assets\www\assets\fonts\ionicons.svg (updated file)
  copy  www\assets\fonts\ionicons.ttf platforms\android\app\src\main\assets\www\assets\fonts\ionicons.ttf (updated file)
  copy  www\assets\fonts\ionicons.woff platforms\android\app\src\main\assets\www\assets\fonts\ionicons.woff (updated file)
  copy  www\assets\fonts\ionicons.woff2 platforms\android\app\src\main\assets\www\assets\fonts\ionicons.woff2 (updated file)
  copy  www\assets\fonts\noto-sans-bold.ttf platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-bold.ttf (updated file)
  copy  www\assets\fonts\noto-sans-bold.woff platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-bold.woff (updated file)
  copy  www\assets\fonts\noto-sans-regular.ttf platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-regular.ttf (updated file)
  copy  www\assets\fonts\noto-sans-regular.woff platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-regular.woff (updated file)
  copy  www\assets\fonts\noto-sans.scss platforms\android\app\src\main\assets\www\assets\fonts\noto-sans.scss (updated file)
  copy  www\assets\fonts\roboto-bold.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.ttf (updated file)
  copy  www\assets\fonts\roboto-bold.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.woff (updated file)
  copy  www\assets\fonts\roboto-bold.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.woff2 (updated file)
  copy  www\assets\fonts\roboto-light.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.ttf (updated file)
  copy  www\assets\fonts\roboto-light.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.woff (updated file)
  copy  www\assets\fonts\roboto-light.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.woff2 (updated file)
  copy  www\assets\fonts\roboto-medium.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.ttf (updated file)
  copy  www\assets\fonts\roboto-medium.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.woff (updated file)
  copy  www\assets\fonts\roboto-medium.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.woff2 (updated file)
  copy  www\assets\fonts\roboto-regular.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.ttf (updated file)
  copy  www\assets\fonts\roboto-regular.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.woff (updated file)
  copy  www\assets\fonts\roboto-regular.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.woff2 (updated file)
  copy  www\assets\fonts\roboto.scss platforms\android\app\src\main\assets\www\assets\fonts\roboto.scss (updated file)
  copy  www\assets\icon\favicon.ico platforms\android\app\src\main\assets\www\assets\icon\favicon.ico (updated file)
  copy  www\assets\imgs\logo.png platforms\android\app\src\main\assets\www\assets\imgs\logo.png (updated file)
  copy  www\build\main.css platforms\android\app\src\main\assets\www\build\main.css (updated file)
  copy  www\build\main.css.map platforms\android\app\src\main\assets\www\build\main.css.map (updated file)
  copy  www\build\main.js platforms\android\app\src\main\assets\www\build\main.js (updated file)
  copy  www\build\main.js.map platforms\android\app\src\main\assets\www\build\main.js.map (updated file)
  copy  www\build\polyfills.js platforms\android\app\src\main\assets\www\build\polyfills.js (updated file)
  copy  www\build\sw-toolbox.js platforms\android\app\src\main\assets\www\build\sw-toolbox.js (updated file)
  copy  www\build\vendor.js platforms\android\app\src\main\assets\www\build\vendor.js (updated file)
  copy  www\build\vendor.js.map platforms\android\app\src\main\assets\www\build\vendor.js.map (updated file)
  copy  www\index.html platforms\android\app\src\main\assets\www\index.html (updated file)
  copy  www\manifest.json platforms\android\app\src\main\assets\www\manifest.json (updated file)
  copy  www\service-worker.js platforms\android\app\src\main\assets\www\service-worker.js (updated file)
Wrote out android application name "TestApp2" to C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\app\src\main\res\values\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "io.ionic.starter" to C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\app\src\main\java\io\ionic\starter\MainActivity.java
Updating icons at platforms\android\app\src\main\res
Updating splash screens at platforms\android\app\src\main\res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
ANDROID_HOME=C:\Users\TECHLAP31\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
Subproject Path: CordovaLib
Subproject Path: app
Running command: cmd "/s /c ""C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\gradlew.bat" cdvBuildDebug -b "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m""

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if "Windows_NT" == "Windows_NT" setlocal

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set DIRNAME=C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\" == "" set DIRNAME=.

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set APP_BASE_NAME=gradlew

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set APP_HOME=C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set DEFAULT_JVM_OPTS=

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if defined JAVA_HOME goto findJavaFromJavaHome

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set JAVA_EXE=C:\Program Files\Java\jdk1.8.0_181/bin/java.exe

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if exist "C:\Program Files\Java\jdk1.8.0_181/bin/java.exe" goto init

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if not "Windows_NT" == "Windows_NT" goto win9xME_args

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set CMD_LINE_ARGS=

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set _SKIP=2

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if "xcdvBuildDebug" == "x" goto execute

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set CMD_LINE_ARGS=cdvBuildDebug -b "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>set CLASSPATH=C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\\gradle\wrapper\gradle-wrapper.jar

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>"C:\Program Files\Java\jdk1.8.0_181/bin/java.exe"    "-Dorg.gradle.appname=gradlew" -classpath "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\\gradle\wrapper\gradle-wrapper.jar" org.gradle.wrapper.GradleWrapperMain cdvBuildDebug -b "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\CordovaLib\build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> com/google/gson/JsonParseException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if "1" == "0" goto mainEnd

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>rem the _cmd.exe /c_ return code!

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>if not "" == "" exit 1

C:\My Drive\Demo\Mobile App\IonicApps\TestApp2>exit /b 1
(node:11532) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\CordovaLib\build.gradle' line: 40

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> com/google/gson/JsonParseException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
    at ChildProcess.whenDone (C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:11532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Command finished with error code 1: cmd /s /c ""C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\gradlew.bat" cdvBuildDebug -b "C:\My Drive\Demo\Mobile App\IonicApps\TestApp2\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m"
  ionic:cli-utils:lib:shell Error in subprocess stdout pipe: Error: write after end at writeAfterEnd (_stream_writable.js:236:12) at Object.Writable.write (_stream_writable.js:287:5) at Readable.write (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:855:33) at DestroyableTransform.ondata (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:619:20) at emitOne (events.js:116:13) at DestroyableTransform.emit (events.js:211:7) at addChunk (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:291:12) at readableAddChunk (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:278:11) at DestroyableTransform.Readable.push (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:245:10) at DestroyableTransform.Transform.push (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_transform.js:148:32) +0ms
  ionic:cli-utils:lib:shell Error in subprocess stderr pipe: Error: write after end at writeAfterEnd (_stream_writable.js:236:12) at Object.Writable.write (_stream_writable.js:287:5) at Readable.write (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:855:33) at DestroyableTransform.ondata (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:619:20) at emitOne (events.js:116:13) at DestroyableTransform.emit (events.js:211:7) at addChunk (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:291:12) at readableAddChunk (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:278:11) at DestroyableTransform.Readable.push (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_readable.js:245:10) at DestroyableTransform.Transform.push (C:\Users\TECHLAP31\AppData\Roaming\npm\node_modules\ionic\node_modules\readable-stream\lib\_stream_transform.js:148:32) +3ms

Thanks for your effort.

Regards.

I also get ‘gradle’ errors sometimes. This is what I do to solve that:

  1. Close all applications you’re using (Better to reboot; this clears running processes faster who may be using the files you’re going to delete)
  2. In your user folder ( C:\Users\XXX\ ) there is a folder called .gradle. Delete the whole folder.
  3. Start Android Studio and create/open a random (empty) project.
  4. You’ll notice down in the status bar that the IDE is downloading and/or installing gradle stuff. Wait for it to finish.

Go back to your Ionic project
5. Delete the platforms, plugins and www folder (optionally node_modules folder too)
6. Execute ionic cordova run android again. Accept when CLI is asking for downloading node_modules etc.

Hope this helps…

1 Like

Are you using any Native Plugin? This sometimes happens when a plugin isn’t compatible with the Android version you’re trying to use

Hello Sir,

i can see the android studio is downloading gradle 4.4-all where as gradle -v command shows gradle version as 4.10. can this be an issue?

Regards,
Deepak

Hello Sir,

i am not using any native plugin, just created a new app and trying to run ionic cordova run android command.

Regards.

Try downgrading to Cordova7.1.0, if you’re using Cordova8.0.0.

Thanks a lot it solved the issue.

Why should changing a global CLI have any effect on what a local platform is doing?

I have no idea, but it worked for me.