[英]Getting Resolve error while importing project in android studio, Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'
I am not able to import a project in AndroidStudio because of following error: 由于以下错误,我无法在AndroidStudio中导入项目:
Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.
I have no idea about the project. 我不知道这个项目。 Why I am getting this error and how do I fix it. 为什么我收到此错误以及如何解决此问题。
I have had a same problem. 我遇到了同样的问题。 And I have found a solution. 我找到了解决方案。
Cause 原因
This problem is caused by android gradle plugin does not match for gradle version . 此问题是由android gradle插件与gradle版本不匹配引起的 。
Solution 解
Edit build.gradle in project. 编辑项目中的build.gradle。 gradle plugin version must be satisfied requirements for android studio. gradle插件版必须满足android studio的要求。
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
And edit distrubutionUrl in gradle/wrapper/gradle-wrapper.properties. 并在gradle / wrapper / gradle-wrapper.properties中编辑distrubutionUrl。 version of gradle must be satisfied requirements for gradle plugin. gradle版本必须满足gradle插件的要求。
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
You can find version compatibilities between android studio, android gradle plugin and gradle in this page 你可以在这个页面找到android studio,android gradle plugin和gradle之间的版本兼容性
Apparently 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling' does not work with the new version of Gradle. 显然,'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'不适用于新版本的Gradle。
Change your project settings so that your project points to an older version of Gradle, like this: 更改项目设置,以便项目指向较旧版本的Gradle,如下所示:
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
EDIT: 编辑:
As noted in a comment, you can also do: 如评论中所述,您还可以:
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
Or even reference other versions. 甚至可以参考其他版本。
Edit build.gradle 编辑build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
And edit gradle/wrapper/gradle-wrapper.properties. 并编辑gradle / wrapper / gradle-wrapper.properties。
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
For me, the problem was that I had set Gradle 1.12 in "Settings..>Gradle" as local gradle distribution, however the project was created by a team mate using gradle 2.2.1 对我来说,问题是我在“设置..> Gradle”中将Gradle 1.12设置为本地gradle分发,但该项目是由团队伙伴使用gradle 2.2.1创建的。
I downloaded gradle 2.2.1 manually and set it as local distribution and problem was solved. 我手动下载了gradle 2.2.1并将其设置为本地分发,问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.