Java Android Studio - Gradle 同步错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27770909/
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
Android Studio - Gradle sync error
提问by Nicolas Bortolotti
I have a synchronization error in Android Studio. I Use: 1.0.2 version from canary channel. Gradle: I tried with version 2.2.1(downloaded from https://www.gradle.org/downloads) and self-download version. JDK: jdk1.8.0_05
我在 Android Studio 中出现同步错误。我使用:来自金丝雀频道的 1.0.2 版本。 Gradle:我尝试使用 2.2.1 版(从https://www.gradle.org/downloads下载)和自下载版本。 JDK:jdk1.8.0_05
I created a new project and the error is always the same:
我创建了一个新项目,错误总是一样的:
Error:Unable to find method 'org.objectweb.asm.ClassReader.getMaxStringLength()I'. Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
错误:无法找到方法“org.objectweb.asm.ClassReader.getMaxStringLength()I”。此意外错误的可能原因包括:
Gradle 的依赖缓存可能已损坏(这有时发生在网络连接超时之后。)
I tried resolve the issue with the invalidation of cache method, and stopping Gradle daemon, but nothing..
我尝试通过缓存方法失效并停止 Gradle daemon 来解决该问题,但没有任何效果..
采纳答案by Scott Barta
Delete the .gradle
directories both in your home directory and at the top level of your project. Gradle's cache directtheitroades aren't affected by the "Clear caches and restart" option.
删除.gradle
主目录和项目顶层的目录。Gradle 的缓存目录不受“清除缓存并重新启动”选项的影响。
回答by kor88
Sorry for a late answer but I hope it will still be useful. I faced the same problem and deleting .gradle directories didn't help.
抱歉回复晚了,但我希望它仍然有用。我遇到了同样的问题,删除 .gradle 目录没有帮助。
Try to reinstall your JDK. In my case I uninstalled my JDK 1.7.0_60 (x64) and JDK 1.8.0_5 (x86). Then I installed JDK 1.8.0_45 (x64) and the problem has gone. HTH.
尝试重新安装 JDK。就我而言,我卸载了 JDK 1.7.0_60 (x64) 和 JDK 1.8.0_5 (x86)。然后我安装了 JDK 1.8.0_45 (x64),问题就解决了。哈。
回答by John Snow
After updating to Android Studio 2.3 I received this error and the top answer didn't work. Following an answer from hereI finally got it fixed.
更新到 Android Studio 2.3 后,我收到了这个错误,最重要的答案不起作用。根据here的答案,我终于解决了。
Go to
去
gradle → wrapper → gradle.wrapper.properties
gradle → 包装器 → gradle.wrapper.properties
And change to distributionUrl to the following:
并将 distributionUrl 更改为以下内容:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip