Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle, Could not expand ZIP appcompat-v7:19.0.1

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'.
like image 535
mrroboaat Avatar asked Feb 01 '14 10:02

mrroboaat


3 Answers

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, .
like image 55
Piyush Agarwal Avatar answered Nov 13 '22 21:11

Piyush Agarwal


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.

like image 4
Sumit Avatar answered Nov 13 '22 21:11

Sumit


Follow these Steps and make Build Successful

  1. cd android cd android/
  2. gradlew clean ./gradlew clean
  3. cd ..
  4. react-native run-android
like image 4
Syed Zain Ali Avatar answered Nov 13 '22 22:11

Syed Zain Ali