0
votes

I've faced this problem while I'm working on Ionic 2. I could run 'ionic serve'. but running on android device is failed. Could someone help me to get over this. Thank you.

Even I've tried the following steps, still getting the same error.

Remove platform : ionic cordova platform rm android

Re add platform : ionic cordova platform add android

Step 1) ionic cordova prepare android

Step 2) ionic cordova build android

Step 3) ionic cordova run android

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:packageDebug'.

    Java heap space

  • 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 44s 47 actionable tasks: 3 executed, 44 up-to-date (node:3775) UnhandledPromiseRejectionWarning: Error: /Users/name/IonicProjects/prjname/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:packageDebug'.

    Java heap space

  • 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 44s at ChildProcess.whenDone (/Users/name/IonicProjects/prjname/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23) at ChildProcess.emit (events.js:127:13) at maybeClose (internal/child_process.js:933:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5) (node:3775) 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) (node:3775) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[OK] Your app has been deployed.

1

1 Answers

0
votes

Please check you have the Android API 23 in order for the Android build and run on device.

After installing above things then try your build commands.

If Even this not work then Try to add the Environment variable

Environment variables > System variables >

add _JAVA_OPTIONS and value = -Xmx512M

For more help please check the same type of issue here.

If this not work for you then try to remove your platforms and node modules and install it again.

I think you have created your project on different environment and building another environment.

Hopes this will help you !!