Error while build apk in Ionic 3

I am getting below error while build apk in ionic application.

[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
        Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
        :wrapper

        BUILD SUCCESSFUL

        Total time: 11.122 secs
        Subproject Path: CordovaLib

        FAILURE: Build failed with an exception.

        * What went wrong:
        Could not dispatch a message to the daemon.

        * 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:
        Could not dispatch a message to the daemon.

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

Result when tried with --stacktrace,–debug

[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.

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

Can anyone please provide any solution for this?