简体   繁体   中英

Android Studio won't compile org/codehaus/groovy/runtime/StringGroovyMethods

Android Studio gradle is getting a groovy error as follows:

Error:(36, 0) Cause: org/codehaus/groovy/runtime/StringGroovyMethods Open File

Haven't been able to resolve this for the most current version of Android Studio Canary version. I have added

classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'

to the Project: build.gradle and I still have an issue, seems like something has a compatibility issues, but not sure what.

Here's some of my version info:

AI-141.2071668 (latest canary build)

Plugins

Android Support Version: 10.1.3 RC 1

Groovy Version: 9.0

Java:

jdk1.7.0_79 and jdk1.7.0_17 (tried both)

Here are my gradle files:

Project: build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

    classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects { repositories { jcenter() } }

My gradle-wrapper.properties file:

#Wed Apr 10 15:27:10 PDT 2013

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

My application build.gradle file:

buildscript {
repositories {
    mavenCentral()

}
dependencies {

}

}

apply plugin: 'com.android.application'

android { compileSdkVersion 21 buildToolsVersion "22.0.1"

defaultConfig {
    applicationId 'com.me.app'
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1101
    versionName "1.1.01"
    multiDexEnabled = true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

}
packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}
productFlavors {
    developercode {
        minSdkVersion 16
        applicationId 'com.me.app'

        targetSdkVersion 21
        versionCode 1101
        versionName '1.1.01'
    }
    eridesharecode {
        minSdkVersion 16
        applicationId 'com.me.app'
        targetSdkVersion 21
        versionCode 1101
        versionName '1.1.01'
    }
}
dexOptions { javaMaxHeapSize "2g" }
compileOptions {
    encoding "UTF-8"
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.squareup.okio:okio:1.1.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'de.keyboardsurfer.android.widget:crouton:1.+@aar'
compile 'com.joanzapata.android:android-iconify:1.0.6'
compile 'com.tundem.aboutlibraries:library:4.0.1@aar'
compile 'com.squareup.retrofit:retrofit:1.7.1'
provided 'com.squareup.dagger:dagger:1.2.+'
compile 'com.google.android.gms:play-services:+'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'de.greenrobot:eventbus:2.1.0'
compile files('libs/nineoldandroids-2.4.0.jar')
provided 'com.squareup.dagger:dagger-compiler:1.2.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.joanzapata.mapper:simple-mapper:1.0.10'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'javax.mail:mail:1.4.7'

}

I have also cleaned out my .gradle folder, *.iml, build folders ... again to no resolution.

I have been able to downgrade Android Studio to version 141.1903250 and it works, but I like to take advantage of the newest Android Studio versions, when they don't break anything.

I did two things to resolve the issue. Add the groovy compile to the build.gradle files and used a older version of gradle.

I change the Project build.gradle file to the folloiwng:

buildscript {
repositories {
    jcenter()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}


dependencies {
    classpath 'com.android.tools.build:gradle:2.2.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

I changed the module build.gradle file as follows:

buildscript {
repositories {
    mavenCentral()

    maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
//        classpath 'com.android.tools.build:gradle:0.10.+'
//        classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.8'
//        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'

}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM