android studio Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'

来源:互联网 发布:apache flink hdfs 编辑:程序博客网 时间:2024/05/22 10:55

今天导入之前的Android studio项目,出了一个很严重的Error,如下:

Error:Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'.Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Google搜了半天也没有找到答案。
分析:由于Gradle经常更新,而且经常出各种奇怪的问题,所以集中在Gradle的问题上,在这里 http://stackoverflow.com/questions/28923716/getting-resolve-error-while-importing-project-in-android-studio-unable-to-load 找到了答案,我的解决方法如下:
1,首先把根目录下的build.gradle文件的classpath改成:

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

2,找到gradle-wrapper.properties文件,其中distributionUrl改成:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip

这样就OK了。。。。

2 0