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.
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.
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.
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
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With