37

I am not able to import a project in AndroidStudio because of following error:

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.

T_C
  • 3,148
  • 5
  • 26
  • 46

5 Answers5

67

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.

Solution

Edit build.gradle in project. gradle plugin version must be satisfied requirements for android studio.

dependencies {
   classpath 'com.android.tools.build:gradle:1.1.0'
}

And edit distrubutionUrl in gradle/wrapper/gradle-wrapper.properties. version of gradle must be satisfied requirements for gradle plugin.

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

gilchris
  • 1,231
  • 17
  • 24
10

Apparently 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling' does not work with the new version of Gradle.

Change your project settings so that your project points to an older version of Gradle, like this:

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.

Jim
  • 10,172
  • 1
  • 27
  • 36
  • 5
    This 1.1.0 gave me exactly the same error. Changing to **com.android.tools.build:gradle:1.0.0** fixed this issue for me. – JaakL Apr 02 '15 at 05:35
  • I updated my Android Studio to 1.3 and same error I got. I just removed caches and wrapper from /.gradle/ directory. and It worked. – Amol Desai Aug 03 '15 at 09:59
5

Edit build.gradle

dependencies {
   classpath 'com.android.tools.build:gradle:1.1.0'
}

And edit gradle/wrapper/gradle-wrapper.properties.

distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Burhan ARAS
  • 2,517
  • 25
  • 19
1

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

I downloaded gradle 2.2.1 manually and set it as local distribution and problem was solved.

Iman Akbari
  • 2,167
  • 26
  • 31
0

I changed Java sdk support in android studio from 20.0.1 to 17.0.6 and it fixed all my issues.