Ionic build android fails in mac

I am trying to build an ionic test application using a mac. The build keeps failing with the following message:

   BUILD SUCCESSFUL
    
    Total time: 5.064 secs
    Subproject Path: CordovaLib
    Unzipping /Users/leoc/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip to 
    /Users/leoc/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9
    Exception in thread "main" java.util.zip.ZipException: error in opening zip file
    	at java.util.zip.ZipFile.open(Native Method)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:169)
    	at org.gradle.wrapper.Install.unzip(Install.java:215)
    	at org.gradle.wrapper.Install.access$600(Install.java:27)
    	at org.gradle.wrapper.Install$1.call(Install.java:75)
    	at org.gradle.wrapper.Install$1.call(Install.java:48)
    	at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
    	at org.gradle.wrapper.Install.createDist(Install.java:48)
    	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
    Error: /Users/leoc/desktop/workspace/testapp/platforms/android/gradlew: Command failed with exit code 1 
    Error output:
    Exception in thread "main" java.util.zip.ZipException: error in opening zip file
    	at java.util.zip.ZipFile.open(Native Method)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:155)
    	at java.util.zip.ZipFile.<init>(ZipFile.java:169)
    	at org.gradle.wrapper.Install.unzip(Install.java:215)
    	at org.gradle.wrapper.Install.access$600(Install.java:27)
    	at org.gradle.wrapper.Install$1.call(Install.java:75)
    	at org.gradle.wrapper.Install$1.call(Install.java:48)
    	at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
    	at org.gradle.wrapper.Install.createDist(Install.java:48)
    	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
    	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

Here are the things I’ve tried so far:

  1. Uninstall and re-install android studio
  2. Delete .gradle directory from the user folder so that it will download it again. At the same time, I also removed and added the android platform using ionic cordova rm/add android command
  3. Defined a new ionic project after re-installing android studio.

None of the steps fixed the problem. I am using ionic version 3.12.0 and cordova version 7.0.1

How can I fix this problem?

Did you try running a sample native application first ? To see if the error come from your android studio setup or your ionic/cordova app. You can also try to reinstall cordova.
You are saying that you are using ionic 3.12.0 but the tag is for ionic-v1. I am missing something

Is ionic cordova requirements happy?
What exact command are you executing?
Did you run anything with sudo before when creating or building this project?
Can you build a new project created with ionic start?

Also post your ionic info output please.

thanks for you questions, i was able to fix the problem. My Android Studio only had the Android SDK platform 26 installed. I just installed platform 25.

1 Like

I think the Ionic version 3.12.0 is for the CLI. Anyway, I was able to fix the problem by installing Android platform 25.

1 Like