Ionic run android - "Undefined" Exception (Ionic 2)

C:\projects\kmmweb5>ionic run android --stacktrace --debug

Running ‘run:before’ gulp task before run
[21:14:09] Starting ‘clean’…
[21:14:09] Finished ‘clean’ after 37 ms
[21:14:09] Starting ‘build’…
[21:14:09] Starting ‘sass’…
[21:14:09] Starting ‘html’…
[21:14:09] Starting ‘fonts’…
[21:14:09] Starting ‘scripts’…
[21:14:09] Finished ‘scripts’ after 44 ms
[21:14:09] Finished ‘html’ after 48 ms
[21:14:09] Finished ‘fonts’ after 55 ms
[21:14:10] Finished ‘sass’ after 934 ms
[21:14:19] Finished ‘build’ after 9.88 s
[21:14:19] Starting ‘run:before’…
[21:14:19] Finished ‘run:before’ after 5.13 μs

Running command: “C:\Program Files\nodejs\node.exe” C:\projects\kmmweb5\hooks\after_prepare\010_add_platform_class.js C:\projects\kmmweb5

add to body class: platform-android

ANDROID_HOME=D:\Android\sdk

JAVA_HOME=C:\Program Files\java\jdk1.8.0_45

No target specified, deploying to emulator

:preBuild
UP-TO-DATE

:preDebugBuild

UP-TO-DATE

:checkDebugManifest

:CordovaLib:preBuild

UP-TO-DATE

:CordovaLib:preDebugBuild

UP-TO-DATE

:CordovaLib:compileDebugNdk
UP-TO-DATE

:CordovaLib:compileLint

:CordovaLib:copyDebugLint UP-TO-DATE

:CordovaLib:mergeDebugProguardFiles

UP-TO-DATE
:CordovaLib:packageDebugRenderscript
UP-TO-DATE

:CordovaLib:checkDebugManifest

:CordovaLib:prepareDebugDependencies

:CordovaLib:compileDebugRenderscript

UP-TO-DATE

:CordovaLib:generateDebugResValues

UP-TO-DATE

:CordovaLib:generateDebugResources UP-TO-DATE

:CordovaLib:packageDebugResources

UP-TO-DATE

:CordovaLib:compileDebugAidl

UP-TO-DATE

:CordovaLib:generateDebugBuildConfig

UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE

:CordovaLib:mergeDebugAssets

UP-TO-DATE

:CordovaLib:processDebugManifest
UP-TO-DATE

:CordovaLib:processDebugResources

UP-TO-DATE

:CordovaLib:generateDebugSources
UP-TO-DATE

:CordovaLib:compileDebugJavaWithJavac
UP-TO-DATE

:CordovaLib:processDebugJavaRes

UP-TO-DATE

:CordovaLib:transformResourcesWithMergeJavaResForDebug

UP-TO-DATE

:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
UP-TO-DATE

:CordovaLib:mergeDebugJniLibFolders

UP-TO-DATE

:CordovaLib:transformNative_libsWithMergeJniLibsForDebug

UP-TO-DATE

:CordovaLib:transformNative_libsWithSyncJniLibsForDebug

UP-TO-DATE

:CordovaLib:bundleDebug

UP-TO-DATE

:prepareAndroidCordovaLibUnspecifiedDebugLibrary
UP-TO-DATE

:prepareDebugDependencies

:compileDebugAidl
UP-TO-DATE

:compileDebugRenderscript
UP-TO-DATE

:generateDebugBuildConfig
UP-TO-DATE

:generateDebugAssets
UP-TO-DATE

:mergeDebugAssets
UP-TO-DATE

:generateDebugResValues

UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources
UP-TO-DATE

:processDebugManifest
UP-TO-DATE

:processDebugResources
UP-TO-DATE

:generateDebugSources UP-TO-DATE
:compileDebugJavaWithJavac
UP-TO-DATE

:compileDebugNdk UP-TO-DATE

:compileDebugSources
UP-TO-DATE

:transformClassesWithDexForDebug
UP-TO-DATE

:mergeDebugJniLibFolders

UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug
UP-TO-DATE

:processDebugJavaRes
UP-TO-DATE

:transformResourcesWithMergeJavaResForDebug
UP-TO-DATE

:validateDebugSigning

:packageDebug

UP-TO-DATE
:zipalignDebug
FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:zipalignDebug’.

A problem occurred starting process ‘command ‘D:\Android\sdk\build-tools\24.0.0\zipalign.exe’’

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

BUILD FAILED

Total time: 2.538 secs

Error: Error code 1 for command: cmd with args: /s,/c,“C:\projects\kmmweb5\platforms\android\gradlew cdvBuildDebug -b C:\projects\kmmweb5\platforms\android\build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true”

Caught exception:
undefined

C:\projects\kmmweb5>ionic --version
2.0.0-beta.32

I cannot figure out what is wrong. I was previously able to run the android emulator when I first started the project. I’ve now done several releases direct to the play store. I’d like to use the emulator again but cannot get past this error. Please help.

Have you tried to google
"Execution failed for task :zipalignDebug exception on Windows"?

I didn’t think of googling for “Windows” but that was a good idea. I’m getting a few more search results I can try out.

Well…after hacking a way for a bit I found that for whatever reason my 24.0.0 build-tools was getting “Permission Denied” via windows when I attempted to run the command manually. Suspicious since other versions ran fine.

I reinstalled version 24.0.0 via android sdk manager and all is well.

Good to know @keeper3000, happy coding!