android – Could not expand Zip in react native project-ThrowExceptions

Exception or error:

I have seen the other questions similar to this on StackOverflow, but I feel like this error pops up all the time, and none of the solutions have really lasted for me. I just recently upgraded our project from React Native version 0.34.1 to 0.42.2 (doing the whole react-native-upgrade process), so I don’t know if that is the cause of all this pain, but I keep getting this error:

* What went wrong:
Execution failed for task ':react-native-awesome-card-io:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library'.
> Could not expand ZIP '/Users/taylorking/.gradle/caches/modules-2/files-2.1/com.facebook.fbui.textlayoutbuilder/textlayoutbuilder/1.0.0/29bc8e5a1e2b33944b88277652ee83092ae1dbc0/textlayoutbuilder-1.0.0.aar'.

It sometimes happens on that package react-native-awesome-card-io, but it could and has happened on any of the packages that the project contains. Sometimes I just keep running react-native run-android, and it eventually resolves itself, but it’s starting to drive me nuts.

I did just do some snooping around for that specific file, and I wanted to check my permissions on it, and it’s showing:

-rw-r--r--  1 taylorking  staff  18074 Mar 16 09:41 textlayoutbuilder-1.0.0.aar

I’m just not even sure if that is the problem or not? I am not too familiar with gradle, but at least most of the posts on this problem deal with that in some form or fashion. I am willing to share any other information that could help solve this once and for all.

Sorry if this seems to be a duplicate, but nothing else has seemed to be the permanent solution on here.

Update:

I just tried deleting that package hoping it would solve my problems, and it just went to the next package with the same error:

* What went wrong:
Execution failed for task ':react-native-camera:prepareComFacebookFrescoDrawee081Library'.
> Could not expand ZIP '/Users/taylorking/.gradle/caches/modules-2/files-2.1/com.facebook.fresco/drawee/0.8.1/a944015ddf50fdad79302e42a85a351633c24472/drawee-0.8.1.aar'.

Update 2:

I ran cd android && ./gradlew clean and it almost finished the cleaning, but it did deny me permission on cleaning the folder related to react-native-camera … the package above. I felt dirty doing this, but I did:

sudo ./gradlew clean

And that fixed this issue for now … is there a better, or more long-term solution still? Opinions and thoughts encouraged.

How to solve:

Just to recap the solution for the quick scrollers.

cd android

sudo ./gradlew clean

Or on Windows:

cd android

gradlew clean

###

Like what @sfratini said in the comments,
Cleaning your gradle is fine every once and a while and it’s not a big deal
So, there is no real long-term solution to this problem

Leave a Reply

Your email address will not be published. Required fields are marked *