gradle, Could not expand ZIP appcompat-v7:19.0.1
Asked Answered
K

16

25

I have a problem with Android Studio and Gradle to import appcompat-v7.

So here is my src/build.gradle:

apply plugin: 'android'
apply plugin: 'android-apt'
def AAVersion = '3.0.1'

    android {
        compileSdkVersion 19
        buildToolsVersion "19.0.1"
    
        defaultConfig {
            minSdkVersion 10
            targetSdkVersion 19
            versionCode 1
            versionName "1.0"
            packageName "com.test"
        }
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    apt {
        arguments {
            resourcePackageName android.defaultConfig.packageName
            androidManifestFile variant.processResources.manifestFile
        }
    }
    
    dependencies {
    
        // You must install or update the Support Repository through the SDK manager to use this dependency.
        // The Support Repository (separate from the corresponding library) can be found in the Extras category.
        compile 'com.android.support:support-v4:19.0.1'
    
        // You must install or update the Support Repository through the SDK manager to use this dependency.
        // The Support Repository (separate from the corresponding library) can be found in the Extras category.
        compile 'com.android.support:appcompat-v7:19.0.1'
    
        // android annotations
        compile "org.androidannotations:androidannotations-api:$AAVersion"
        apt "org.androidannotations:androidannotations:$AAVersion"
    }

But I get the following error:

Execution failed for task ':app:prepareComAndroidSupportAppcompatV71901Library'.
> Could not expand ZIP '/opt/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/19.0.1/appcompat-v7-19.0.1.aar'.
Kisumu answered 1/2, 2014 at 10:58 Comment(4)
Make sure the .aar file is there in the directory mentioned in error. it might be possible that your file is currpted, You can delete the m2repository and download it again.Denna
The path is correct. I've tried to delete the m2repository and dowload it again but the error is still here.Kisumu
chek my answer and let me know if it solves your problem.Denna
Does --stacktrace give more information?Koweit
D
24

It seems the issue is with directories permissions .

Check and try following things :

  • Check whether you have write access on both the android sdk and Android Studio directories.
  • if you are on Windows OS, also try to run Android Studio as Administrator by right clicking on the Studio's icon, .
Denna answered 1/2, 2014 at 17:19 Comment(7)
Exactly. It was a permission problem on my ubuntu OS. In fact, my projects are stored on other partition and this project was created by root. I have modified my /etc/fstab to add the right uid and now everything is ok.Kisumu
great @Youngjae , it makes me feel good when my contribution help somebody.Denna
@aat can you please more widely explain what you did? I have same issue. I checked partition permissions and they seems to be ok. Usually I'm setting write permission to full project-dir but it help only temporary and then after some time repeating again.Lachrymator
@grub- Honnestly, I don't really remember what I did. Since the last time, I've installed a new OS and I have not the problem anymore ...Kisumu
In my case (working on a Mac), I did have the wrong permissions on /Applications/Android (it was owned by root instead of my user), but also the build directory on my project was owned by root (I built on the command line using sudo probably, and then was getting this error when building on Android Studio) which was causing this error.Highly
Any suggestions which file permissions will fail? On my Ubuntu I have 777 on the project and reading from /opt/android-studio/ and writing to ./grade/ also is possible... But my only solution to solve the issue so far, was sudo ./studio.sh.Antidepressant
After running the Android Studio as administrator, once, building as non-root user works. As long, as I won't click "Clean Projekt"...Antidepressant
C
4

Just wanted to add my experience. I was getting this error for a kafka jar

FAILURE: Build failed with an exception.

* What went wrong:
Could not expand ZIP '/home/srangwal/.gradle/caches/modules-2/files-2.1/org.apache.kafka/kafka_2.9.2/0.8.2.0/f9e44ac2d80afee7d5696f11814e6a65af5a380a/kafka_2.9.2-0.8.2.0.jar'.
> Could not copy zip entry /home/srangwal/.gradle/caches/modules-2/files-2.1/org.apache.kafka/kafka_2.9.2/0.8.2.0/f9e44ac2d80afee7d5696f11814e6a65af5a380a/kafka_2.9.2-0.8.2.0.jar!kafka/consumer/ZookeeperConsumerConnector$ZKRebalancerListener$$anonfun$kafka$consumer$ZookeeperConsumerConnector$ZKRebalancerListener$$addPartitionTopicInfo$1.class to '/home/srangwal/work-projects/griffin/build/tmp/expandedArchives/kafka_2.9.2-0.8.2.0.jar_7e6mtfrbv2j9f9v18u5gsfe9q/kafka/consumer/ZookeeperConsumerConnector$ZKRebalancerListener$$anonfun$kafka$consumer$ZookeeperConsumerConnector$ZKRebalancerListener$$addPartitionTopicInfo$1.class'.

To debug, I tried to touch the file that gradle was trying to create, since permissions of all my directories were fine

touch '/home/srangwal/work-projects/griffin/build/tmp/expandedArchives/kafka_2.9.2-0.8.2.0.jar_7e6mtfrbv2j9f9v18u5gsfe9q/kafka/consumer/ZookeeperConsumerConnector$ZKRebalancerListener$$anonfun$kafka$consumer$ZookeeperConsumerConnector$ZKRebalancerListener$$addPartitionTopicInfo$1.class'
touch: cannot touch ‘/home/srangwal/work-projects/griffin/build/tmp/expandedArchives/kafka_2.9.2-0.8.2.0.jar_7e6mtfrbv2j9f9v18u5gsfe9q/kafka/consumer/ZookeeperConsumerConnector$ZKRebalancerListener$$anonfun$kafka$consumer$ZookeeperConsumerConnector$ZKRebalancerListener$$addPartitionTopicInfo$1.class’: File name too long

I was getting this error because I was working on an encrypted filesystem in ubuntu and the encrypted filesystem did not allow very long filenames.

Camala answered 6/8, 2015 at 23:55 Comment(0)
J
4

If you're on *UNIX, you can run this command from the Android Studio command line

sudo chmod -R 777 /your/project/path
Jotting answered 22/2, 2016 at 21:44 Comment(4)
When I try this (Windows 7) I just get 'sudo' is not recognized as an internal or external command, operable program or batch file.Slight
I've now posted the problem/question here: #37922286Slight
@ChandlerSwift and macOSJotting
I have similar problem (Could not expand ZIP XXXX/.gradle/caches/modules-2/files-2.1/android.arch.lifecycle/runtime/XXX), this works well, thanks.Remonstrance
C
4

Follow these Steps and make Build Successful

  1. cd android cd android/
  2. gradlew clean ./gradlew clean
  3. cd ..
  4. react-native run-android
Chieftain answered 21/12, 2017 at 18:49 Comment(0)
T
2

I had the same problem when I've tried to build project in IntelliJ IDEA 13.1.4 and my multi-module project today. Not very good solution, but I've unchecked "Compile independent modules in parallel (may require larger heap space)" and problem disappeared. Moreover, Gradle configuration for my project probably isn't ideal (but i can still successfully build project via command line) and i'm checking weak places.

Takeover answered 10/9, 2014 at 10:15 Comment(0)
S
2

I found someone with the same problem here.

The solution - albeit a temporary one - is to downgrade from Gradle 2.1.0 to 2.0.0 in my project's build.gradle file.

Slight answered 11/5, 2016 at 11:21 Comment(8)
This actually worked for me, co incidentally i had the problem with the same jar nxpnfclib and hence this solution worked.Pendent
@monotheist Did you ever find a better solution? (I'm still getting this same issue with Gradle 2.1.2, so am currently stuck on Gradle 2.0.0 .)Slight
not yet, are u facing the problem with the same lib file? or different?Pendent
Same lib file - nxpnfclib.jar .Slight
looks like the lib has a problem with 2.1.2, only NXP can fix it in their lib codePendent
After a very protracted conversation with one of the NXP technical guys, they now have an intermediate release - nxp.app.box.com/s/hmbwjzac6jc9gw2qjkd9xtxs745me4s9 - which they say will work with Android Studio 2.1.2 . I expect the official release will be in the near future.Slight
Anyone else also having this other (new) problem with nxpnfclib.jar?... #39083838Slight
Incidentally, NXP have now changed over from nxpnfclib.jar to the Tap Linx library - which, unfortunately, also has its issues... :-/Slight
A
2

Guys this "COULD" be the problem that your Library is not compatible with the gradle version as it was with me. So I reduced the gradle version and it worked. I suggest that you try changing your gradle version and then build again. Hope it helps someone.

Aargau answered 17/4, 2017 at 9:33 Comment(0)
L
1

In my case it was a windows permission problem. The project was created from Cygwin, and all folders had strange permissions

Labored answered 26/3, 2015 at 14:32 Comment(0)
R
0

I'm an Ubuntu user and I had the same problem. I followed pyus13's answer and I gave the write permissions to the project folder instead of giving it to android-studio and android-sdk-linux. Also, the command
sudo chmod 7777 /your/project/path
didn't work. But,
sudo chmod 757 -R /your/project/path
worked perfectly.

Radiotelegraph answered 2/2, 2016 at 6:4 Comment(0)
U
0

Ubuntu user here; I stumbled across this problem after backing up my library on a mounted USB, then finding that the permissions had been changed on the project folder after reverting from a backup.

To restore access, I peformed the following steps:

  1. Allow R/W access to the Android project folder. sudo chmod -R 777 ./MyProjectDir

  2. Open the project in Android Studio. After gradle has finished indexing, clean the build.

Uxmal answered 27/4, 2017 at 22:59 Comment(0)
T
0

I had the same issue with our own library. The final .aar contained a non valid .so filename inside.

Cleanup all the dependencies and rebuilt fixed the issue.

I found the issue by enabling --stacktrace with Gradle.

Tamas answered 13/2, 2018 at 9:10 Comment(0)
A
0

For me the issue was with the folder that the file was being unzipped to. Deleting that and running the build again sorted it out

Anisole answered 23/3, 2018 at 15:39 Comment(0)
G
0

Run cd android && gradlew clean && cd.. && react-native run-android

Gregoriogregorius answered 10/6, 2018 at 12:27 Comment(0)
A
0

in my case it was the AAR too large,and i don't use the git lfs

Alpenhorn answered 29/11, 2019 at 2:0 Comment(0)
K
-2
  • If you are using jdk1.8., Remove it.
  • Installing jdk1.7.
Kristinkristina answered 17/9, 2014 at 19:19 Comment(2)
Worked for me, I had the same error, the project I was working on was meant to run on jdk 1.7 and my environment had jdk 1.8.Choe
Worked perfectly for me. Downgrading was the last thing I did, but turned out it was what was required. Thank you.Extenuatory
P
-2

i think i can help you,you should try to remove your project to your Ubuntu user directory,like /home/username/, then, reload your project and work it.

Primo answered 14/7, 2015 at 2:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.