简体   繁体   English

更新到Android Studio 2.3之后,构建gradle无法构建

[英]After updating to Android Studio 2.3 build gradle is not able to build

Error:Failed to open zip file. 错误:无法打开zip文件。

Gradle's dependency cache may be corrupted (this sometimes occurs after a network connection timeout.) Gradle的依赖性缓存可能已损坏(这有时会在网络连接超时后发生。)

<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>

This happened yesterday. 这发生在昨天。 I'm not able to run any of my old project and I can't download this dependency though I have good internet connection. 我无法运行任何旧项目,虽然我有良好的互联网连接,但我无法下载此依赖项。

I had a similar issue today after updating to Android Studio 2.3. 在更新到Android Studio 2.3后,我今天遇到了类似的问题。

I had to update my build tools to 25.0.0 you can do this by changing the buildToolsVersion and changing the compileSdkVersion to 25 in the build.gradle file in your main module. 我必须将我的构建工具更新到25.0.0你可以通过更改buildToolsVersion并在主模块的build.gradle文件中将buildToolsVersion更改为25来实现。

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    ...
}

I've had the same error and resolve by simply doing 我只是做了同样的错误和决心

Build > Clean 建立>清洁

Build > Rebuild 构建>重建

If it does not work, refer to the link below. 如果不起作用,请参阅以下链接。

https://stackoverflow.com/a/42609533/1358117 https://stackoverflow.com/a/42609533/1358117

Steps to solve this problem: 解决此问题的步骤:

1) Replace Dependencies in build.gradle (project) by this code : 1)通过以下代码替换build.gradle(项目)中的依赖项:

classpath 'com.android.tools.build:gradle:2.3.0' classpath'com.android.tools.build:grad:2.3.0'

2) Replace distributionUrl in Gradle-wrapper.properties by this code: 2)用以下代码替换Gradle-wrapper.properties中的distributionUrl:

distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl = HTTPS://services.gradle.org/distributions/gradle-3.3-all.zip

3) Don't forget to use Gradle default wrapper in Project level setting. 3)不要忘记在项目级别设置中使用Gradle默认包装器。

I also encountered this problem after accepting an update. 接受更新后我也遇到了这个问题。 I'm not sure if this is the right approach, but it solved this problem for me. 我不确定这是否是正确的方法,但它为我解决了这个问题。

In build.gradle (Project), I replaced with the following: 在build.gradle(Project)中,我替换为以下内容:

classpath 'com.android.tools.build:gradle:1.5.0'

And in build.gradle (Module:app), 在build.gradle(Module:app)中,

buildToolsVersion '23.0.1'

After which I Synced Project with Gradle Files. 之后,我使用Gradle文件同步项目。 Everything worked fine afterwards, hope it helps you. 事后一切都很好,希望它对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM