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.