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

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


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    atjava.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


I can fix this error message using these three methods.

  1. use latest gradle version
  2. use latest android SDK and tools.
  3. use proguard-rules.pro

build.gradle (Project:xxxxx)

buildscript {    repositories {        mavenCentral()    }    dependencies {         classpath 'com.android.tools.build:gradle:1.2.3'    }}allprojects {    repositories {        mavenCentral()    }}

build.gradle (Module:app)

apply plugin: 'android'android {    compileSdkVersion 22    buildToolsVersion "21.1.2"    defaultConfig {        minSdkVersion 11        targetSdkVersion 19        versionCode 1        versionName "1.0"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }}dependencies {    compile 'com.android.support:appcompat-v7:+'    compile fileTree(dir: 'libs', include: ['*.jar'])}


I had the same problem. I ran gradle from command line and that did work.After that, I found File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. There "Use local gradle distribution" was active. Changed it to "Use default gradle wrapper (recommended)" and it worked.