Android gradle,无法扩展 ZIP appcompat-v7:19.0.1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21497181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:39:55  来源:igfitidea点击:

gradle, Could not expand ZIP appcompat-v7:19.0.1

androidgradleandroid-studioandroid-appcompat

提问by mrroboaat

I've a problem with android studio adn gradle to import appcompat-v7.

我在使用 android studio 和 gradle 导入 appcompat-v7 时遇到问题。

So here is my build.gradle in the src directory

所以这是我在 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'.

How can I solve my problem ? Thx in advance

我该如何解决我的问题?提前谢谢

回答by pyus13

It seems the issue is with directories permissions .

似乎问题出在目录权限上。

Check and try following things :

检查并尝试以下事项:

  • Check whether you have write access on both the android sdkand Android Studiodirectories.
  • if you are on Windows OS, also try to run Android Studio as Administrator by right clicking on the Studio's icon, .
  • 检查您是否对android sdkAndroid Studio目录都有写访问权限。
  • 如果您使用的是 Windows 操作系统,还可以通过右键单击 Studio 的图标,尝试以管理员身份运行 Android Studio。

回答by Oded Breiner

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

如果您使用的是 *UNIX,则可以从 Android Studio 命令行运行此命令

sudo chmod -R 777 /your/project/path

回答by Sumit

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

只是想补充一下我的经验。我收到了 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.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.class'.

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

为了调试,我尝试触摸 gradle 试图创建的文件,因为我所有目录的权限都很好

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.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.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.

我收到此错误是因为我在 ubuntu 中处理加密文件系统,并且加密文件系统不允许很长的文件名

回答by Syed Zain Ali

Follow these Steps and make Build Successful

遵循这些步骤,使构建成功

  1. cd android cd android/
  2. gradlew clean ./gradlew clean
  3. cd ..
  4. react-native run-android
  1. 光盘安卓 cd android/
  2. 渐变干净 ./gradlew clean
  3. 光盘..
  4. react-native run-android

回答by ban-geoengineering

I found someone with the same problem here.

我在这里找到了有同样问题的人

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

解决方案 - 尽管是临时解决方案 - 是在我的项目的 build.gradle 文件中从 Gradle 2.1.0 降级到 2.0.0。

回答by Lazycoder_007

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.

伙计们,这个“可能”是您的图书馆与我的 gradle 版本不兼容的问题。所以我减少了 gradle 版本并且它起作用了。我建议您尝试更改 gradle 版本,然后重新构建。希望它可以帮助某人。

回答by Igor K

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.

我今天尝试在 IntelliJ IDEA 13.1.4 和我的多模块项目中构建项目时遇到了同样的问题。不是很好的解决方案,但我已经取消选中“并行编译独立模块(可能需要更大的堆空间)”并且问题消失了。此外,我的项目的 Gradle 配置可能并不理想(但我仍然可以通过命令行成功构建项目)并且我正在检查薄弱的地方。

回答by gervais.b

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

在我的情况下,这是一个 Windows 权限问题。该项目是从 Cygwin 创建的,所有文件夹都有奇怪的权限

回答by Mapsy

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.

Ubuntu 用户在这里;在已安装的 USB 上备份我的库后,我偶然发现了这个问题,然后发现从备份恢复后,项目文件夹的权限已更改。

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, cleanthe build.

  1. 允许 R/W 访问 Android 项目文件夹。 sudo chmod -R 777 ./MyProjectDir

  2. 在 Android Studio 中打开项目。在 gradle 完成索引后,clean构建。

回答by punisher_malade

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

我们自己的图书馆也有同样的问题。最后的 .aar 包含一个无效的 .so 文件名。

Cleanup all the dependencies and rebuilt fixed the issue.

清理所有依赖项并重建修复了问题。

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

我通过使用 Gradle 启用 --stacktrace 发现了这个问题。