Android build fails but was working

So 2 days ago my Ionic app built fine when building for Android. Now it will not build and errors out complaining that it can’t open the apk as a zip archive. I am unsure of what changed, as I didn’t ass or remove any plugins. It literally worked one day and when I came back to it the next day it didn’t. Building for iOS works fine, it just fails building for Android. Also I have noticed that the build takes 200x longer to process. Where 2 days ago running a ‘ionic bulild android’ would take a few seconds, now it takes about 1 minute to run and error out.

I have uninstalled all platforms from Ionic and Cordova, cleared the cache, even installed a new VM and rebuilt the app from scratch on a clean system and it still fails. Any help would be appreciated.

$ ionic build android
Running command: /Users/nhudson/code/git/nhudson/beerList/hooks/after_prepare/010_add_platform_class.js /Users/nhudson/code/git/nhudson/beerList
add to body class: platform-android
Running command: /Users/nhudson/code/git/nhudson/beerList/platforms/android/cordova/build
ANDROID_HOME=/Users/nhudson/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
Running: /Users/nhudson/code/git/nhudson/beerList/platforms/android/gradlew cdvBuildDebug -b /Users/nhudson/code/git/nhudson/beerList/platforms/android/build.gradle -Dorg.gradle.daemon=true
embedded
WARNING [Project: :] Current NDK support is deprecated. Alternative will be provided in the future.
WARNING [Project: :] Current NDK support is deprecated. Alternative will be provided in the future.
WARNING [Project: :] Current NDK support is deprecated. Alternative will be provided in the future.
WARNING [Project: :] Current NDK support is deprecated. Alternative will be provided in the future.
org.xwalk:xwalk_core_library:15+
:preBuild
:compileArmv7DebugNdk UP-TO-DATE
:preArmv7DebugBuild
:checkArmv7DebugManifest
:preX86DebugBuild
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:preBuild
:CordovaLib:preDebugBuild
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJava UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:packageDebugJar UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:packageDebugJniLibs UP-TO-DATE
:CordovaLib:packageDebugLocalJar UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:preArmv7ReleaseBuild
:preX86ReleaseBuild
:CordovaLib:copyReleaseLint UP-TO-DATE
:CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
:CordovaLib:preReleaseBuild
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseAidl UP-TO-DATE
:CordovaLib:compileReleaseRenderscript UP-TO-DATE
:CordovaLib:generateReleaseBuildConfig UP-TO-DATE
:CordovaLib:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseAssets UP-TO-DATE
:CordovaLib:generateReleaseResValues UP-TO-DATE
:CordovaLib:generateReleaseResources UP-TO-DATE
:CordovaLib:packageReleaseResources UP-TO-DATE
:CordovaLib:processReleaseManifest UP-TO-DATE
:CordovaLib:processReleaseResources UP-TO-DATE
:CordovaLib:generateReleaseSources UP-TO-DATE
:CordovaLib:compileReleaseJava UP-TO-DATE
:CordovaLib:processReleaseJavaRes UP-TO-DATE
:CordovaLib:packageReleaseJar UP-TO-DATE
:CordovaLib:compileReleaseNdk UP-TO-DATE
:CordovaLib:packageReleaseJniLibs UP-TO-DATE
:CordovaLib:packageReleaseLocalJar UP-TO-DATE
:CordovaLib:packageReleaseRenderscript UP-TO-DATE
:CordovaLib:bundleRelease UP-TO-DATE
:prepareOrgXwalkXwalk_core_library154438413Library UP-TO-DATE
:prepareArmv7DebugDependencies
:compileArmv7DebugAidl UP-TO-DATE
:compileArmv7DebugRenderscript UP-TO-DATE
:generateArmv7DebugBuildConfig UP-TO-DATE
:generateArmv7DebugAssets UP-TO-DATE
:mergeArmv7DebugAssets
:createXwalkCommandLineFileArmv7Debug
:generateArmv7DebugResValues UP-TO-DATE
:generateArmv7DebugResources UP-TO-DATE
:mergeArmv7DebugResources UP-TO-DATE
:processArmv7DebugManifest UP-TO-DATE
:processArmv7DebugResources
:generateArmv7DebugSources
:compileArmv7DebugJava UP-TO-DATE
:preDexArmv7Debug UP-TO-DATE
:dexArmv7Debug UP-TO-DATE
:processArmv7DebugJavaRes UP-TO-DATE
:validateDebugSigning
:packageArmv7Debug
:zipalignArmv7DebugUnable to open ‘/Users/nhudson/code/git/nhudson/beerList/platforms/android/build/outputs/apk/android-armv7-debug-unaligned.apk’ as zip archive
FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:zipalignArmv7Debug’.
    > Process ‘command ‘/Users/nhudson/Library/Android/sdk/build-tools/23.0.1/zipalign’’ finished with non-zero exit value 1

  • 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 mins 40.489 secs

/Users/nhudson/code/git/nhudson/beerList/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/nhudson/code/git/nhudson/beerList/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/nhudson/code/git/nhudson/beerList/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/nhudson/code/git/nhudson/beerList/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/nhudson/code/git/nhudson/beerList/platforms/android/cordova/build: Command failed with exit code 1

$ cordova plugin list

cordova-plugin-console 1.0.1 "Console"
cordova-plugin-crosswalk-webview 1.4.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-keyboard 1.0.8 “Keyboard”

$ ionic info

Your system information:

Cordova CLI: 5.4.1
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.11
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.8.2
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v5.1.0
Xcode version: Xcode 7.1.1 Build version 7B1005

A bit more info on this. After some digging around, I noticed that I did install a package called ‘material-design-icons’ through bower. Uninstalling this package results in the build completing. While it adds 341mb to the overall size of the project directory, I don’t see what or how this would cause the build to fail.

Looks like I will have to redesign my app to use something else now, since for some reason this causes issues building for Android.

Sounds really similar to what I was seeing, the Material components were not found by the latest instabug library that pushed 2 days ago, because it uses android support library 23.1.1.

I went into Android Studio and made sure in gradle that my app compiled with using 23 (instead of 22 as before), but that also lead me to find that I didn’t have the proper 23 build tools, or the support libraries installed. I used Android Studio to get those properly installed, then I was able to roll in the latest instabug, that was calling for Material.widget.button and failing.

Yeah thanks for the reply. I actually read over your post about this yesterday in hopes to help me try to figure out what is going on. What’s funny is that if I remove all calls to the material-design-icons from my index.html and my app.js, the build still fails. If I physically remove the directory from www/lib/ the build works fine. I don’t have much experience using Android Studio, but I am able to import the Gradle project, build the app and run it in an emulator or on my phone. Adding the material-design-icon package back into the Ionic project or in my Android Studio project will result in the build failing on both sides. It’s almost like the folder itself is too large to handle.

I think I can work around it by importing other icons, but still seems like an issue.