Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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.

like image 347
T_C Avatar asked Mar 08 '15 06:03

T_C


People also ask

How to fix Gradle not responding in Android Studio?

In this click on Invalidate Caches and Restart option to Restart your Android Studio project. After restarting your Android Studio the Gradle issue will be fixed. This issue will not be solved if the folder containing Gradle files is deleted or corrupted. In such a case, you have to download new files for Gradle.

How to fix Android Studio can’t open libraries?

Step 1: Delete the .idea folder. For .idea folder navigate to YourProject > app > .idea Exit Android Studio and reopen it. Restart Android Studio. It should now recreate the libraries folder and work again.

How to open an existing Android Studio project?

Open your Android Studio and if any project is opened just close it (Go to File->Close Project) then you'll see a small window like this: Open Android Studio project: Click on "Open an existing Android Studio project" to open Android Studio project

How to sync Android Studio project with Gradle files?

After deleting this folder we have to reopen our Android studio and then navigate to the Files option in the top bar and then click on Sync Project with Gradle Files to sync your project it will automatically download the new Gradle files which are required for your project. You can get to see this option on the below screenshot.


2 Answers

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

like image 152
gilchris Avatar answered Sep 20 '22 20:09

gilchris


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.

like image 31
Jim Avatar answered Sep 20 '22 20:09

Jim