Getting error while 'ionic cordova build android' in Ionic

Hello,

I am getting below error while apk build using “ionic cordova build android”

[ERROR] An error occurred while running cordova build android (exit code 1):

        ANDROID_HOME=C:\Users\XYZ\AppData\Local\Android\sdk
        JAVA_HOME=C:\Program Files\java\jdk1.8.0_31
        :wrapper

        BUILD SUCCESSFUL

        Total time: 0.862 secs
        Subproject Path: CordovaLib

        FAILURE: Build failed with an exception.

        * What went wrong:
        Received invalid response from the daemon: 'org.gradle.launcher.daemon.protocol.ForwardInput@5b6ec132' is a
        result of a type we don't have a strategy to handle. Earlier, 'Build{id=ce257caf-e024-4abd-90a8-72d733ea91d7.1,
        currentDir=D:\app}' request was sent to the daemon.
        Diagnostics:
        No diagnostics available.

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
        Error: cmd: Command failed with exit code 1 Error output:
        FAILURE: Build failed with an exception.

        * What went wrong:
        Received invalid response from the daemon: 'org.gradle.launcher.daemon.protocol.ForwardInput@5b6ec132' is a
        result of a type we don't have a strategy to handle. Earlier, 'Build{id=ce257caf-e024-4abd-90a8-72d733ea91d7.1,
        currentDir=D:\app}' request was sent to the daemon.
        Diagnostics:
        No diagnostics available.

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

Below configuration I am using for app:

node : v6.9.5
npm : 3.10.10
Ionic: 3.9.1
"cordova-android": “^6.2.3”

I have tried with --stacktrace , --info and --debug options but getting same details of build failure.

Can anyone please help me to solve this error?

Huh, that’s a strange one I haven’t seen before.

Did you google for the error already?

First measure: Remove the Android platform and add it again.

If this doesn’t help, please run ionic info and post the output.
Also run cordova requirement and post that too.

Thanks for the reply.
Yes, I have google for the error but did not get any related solution.

I have tried with “Remove the Android platform and add it again” but getting same error.

ionic info output:

   @ionic/cli-utils  : 1.9.1
    ionic (Ionic CLI) : 3.9.1

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.5.3

System:

    Node : v6.9.5
    npm  : 3.10.10
    OS   : Windows 10

cordova requirements output:

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-25
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle

Ok, this all looks good.

The problem seems to be in gradle, which is used by the Android project to build itself. But I have no idea what the error message actally means.

Create a new project with ionic start blank blank and try to build that for Android. Same error?

I have created new project with ionic start blank blank and tried to build for android, but got the same error.

Ok, so this is not a project specific problem.

Uninstall everything Android and reinstall it on your machine (Gradle, Android SDK, Android Studio…). Maybe something is borked in here somewhere.