Android Studio Unable to load class 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'

EvilBurrito picture EvilBurrito · Mar 31, 2015 · Viewed 7.8k times · Source

I installed Android Studio and when I try to import a project from gradle this resolve error shows up:

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

I deleted the files in my Users .gradle folder and tried different gradle versions. I don't know how to fix this.

Answer

Vlad picture Vlad · Jun 4, 2015

This page might help solve the problem. What they say is:

So we leveraged this version to add a new artifact, named groovy-backports-compat23. This artifact shouldn’t be necessary for most of you, but if you face an error like:

Caused by: java.lang.ClassNotFoundException:
org.codehaus.groovy.runtime.typehandling.ShortTypeHandling    at
java.net.URLClassLoader$1.run(URLClassLoader.java:372)

in your project, then it means that a class has been compiled with Groovy 2.3+ but that you are trying to use it with an older version of Groovy. By adding this jar on classpath, you give a chance to your program to run. This may be particularily interesting for Gradle users that want to use a plugin built on Gradle 2+ on older versions of Gradle and face this error. Adding the following line to their build files should help:

buildscript {
    // ...
    dependencies {
         classpath 'some plugin build on gradle 2'
         classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
    } }

Note that for now, this jar only contains the ShortTypeHandlingClass. Future versions may include more. - See more at: http://glaforge.appspot.com/article/groovy-2-3-5-out-with-upward-compatibility#sthash.mv7Y8XQv.dpuf