Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to gradle 2.1.0 causes – Could not expand ZIP error

I recently updated my Android project's gradle plugin to 2.1.0 from 2.1.0-alpha4. But now I see that all my builds fail with a message like so:

Error:Execution failed for task ':App:compileUpdemoDebugJavaWithJavac'.
> Could not expand ZIP '/Users/admin/work/app/libs/lib-android-0.11.0.jar'.

If I revert my gradle plugin to the previous 2.1.0-alpha4 version, set the environment variable ANDROID_DAILY_OVERRIDE and then build my project — everything works just fine.

Has anyone else come across this problem? I believe this is related to the latest plugin, and so, people might just start to stumble across this problem.

Any possible solutions? (I am aware of some workarounds, like extracting the JAR and making gradle skip the JAR extraction process, but that certainly doesn't sound worth the effort!)

like image 343
anirvan Avatar asked May 05 '16 18:05

anirvan


3 Answers

Follow below step to set automatically gradle sync in your android studio.

File -> Settings -> Build,Execution,Deployment ->Build tools -> gradle -> check Use Default gradle wrapper(recommended) radiobutton.

Also follow below step to restart your android studio for invalid cache restart.

File > Invalidate Caches/Restart (you can also manually remove the cache at ~/Library/Caches/{yourIDEName} and restart the IDE)

Then save settings and rebuild your project.

like image 193
pRaNaY Avatar answered Nov 02 '22 01:11

pRaNaY


Unfortunately, most of the answers posted here didn't work out. Although, logically speaking, @Kowshick's answer seemed to tackle the right thing — i.e, there's something wrong with the directory permissions. However, giving 777 access can't be the right thing, and the default 755 that I had on my development folder, sdk folder, build folder — should've worked just fine. But it didn't. :(

Eventually, what I realised is that there are only 3 ways to resolve this problem:

  1. Wait for Google to release an update to its build tools, which would update the gradle plugin, and hopefully resolve this issue.
  2. And while you wait for the above to happen, the only thing that worked for me was to downgrade the gradle plugin to version 2.0.0. The very fact that it works by downgrading, shows that the real issue isn't with the directory permissions I have.
  3. Finally, there's this rather frustrating thing you can do — create a separate user on your system, and setup your project from scratch — download Android Studio, SDK and your workspace. There's a good chance it'll work, but it's a horrible way to work. And on top of that, if you don't have an OS which supports fast user switching, you're just going to feel a world of pain.

In my case, I survived using option # 2 for some time, and I was just lucky that I had my hard drive upgraded to an SSD, so I finally ended up doing option # 3 too (since I made a fresh install of my OS on the SSD).

Other info:
OS — OS X (El Capitan)
Android studio — 2.1.0

like image 3
anirvan Avatar answered Nov 02 '22 02:11

anirvan


From what I can see your project is in admin directory /Users/admin/work/app/libs/lib-android-0.11.0.jar.

1) Either you could try moving your project path to some user directory,like /home/username/

2) Or you could give write permission to you project path by using

sudo chmod 777 -R /Users/admin/work/app/

Guess this helps.

like image 1
Kowshick Avatar answered Nov 02 '22 00:11

Kowshick