Reputation: 5692
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'.
Upvotes: 25
Views: 49900
Reputation: 29739
If you're on *UNIX, you can run this command from the Android Studio command line
sudo chmod -R 777 /your/project/path
Upvotes: 4
Reputation: 868
Run cd android && gradlew clean && cd.. && react-native run-android
Upvotes: 0
Reputation: 2168
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
Upvotes: 0
Reputation: 61
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.
Upvotes: 0
Reputation: 1226
Follow these Steps and make Build Successful
cd android/
./gradlew clean
Upvotes: 4
Reputation: 4262
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:
Allow R/W access to the Android project folder. sudo chmod -R 777 ./MyProjectDir
Open the project in Android Studio. After gradle has finished indexing, clean
the build.
Upvotes: 0
Reputation: 1205
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.
Upvotes: 2
Reputation: 18871
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.
Upvotes: 2
Reputation: 741
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.
Upvotes: 0
Reputation: 2264
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.
Upvotes: 4
Reputation: 1
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.
Upvotes: -2
Reputation: 2347
In my case it was a windows permission problem. The project was created from Cygwin, and all folders had strange permissions
Upvotes: 1
Reputation: 470
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.
Upvotes: 2
Reputation: 25858
It seems the issue is with directories permissions .
Check and try following things :
Upvotes: 24