![](/img/trans.png)
[英]Android Studio Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
[英]Android Studio won't compile org/codehaus/groovy/runtime/StringGroovyMethods
Android Studio gradle出現如下錯誤:
錯誤:(36,0)原因:org / codehaus / groovy / runtime / StringGroovyMethods打開文件
無法針對最新版本的Android Studio Canary版本解決此問題。 我已經添加了
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
到項目:build.gradle,我仍然有一個問題,似乎有些東西具有兼容性問題,但不確定是什么。
這是我的一些版本信息:
AI-141.2071668(最新的金絲雀版本)
外掛程式
Android支持版本:10.1.3 RC 1
Groovy版本:9.0
Java:
jdk1.7.0_79和jdk1.7.0_17(均嘗試)
這是我的gradle文件:
項目: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 {儲存庫{jcenter()}}
我的gradle-wrapper.properties文件:
#Wed Apr 10 15:27:10 PDT 2013
distributionBase = GRADLE_USER_HOME distributionPath =包裝器/ dists zipStoreBase = GRADLE_USER_HOME zipStorePath =包裝器/ dists distributionUrl = https://services.gradle.org/distributions/gradle-2.2.1-all.zip
我的應用程序build.gradle文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
}
}
應用插件:“ 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'
}
我還清理了我的.gradle文件夾* .iml,構建文件夾...再次沒有解析。
我已經能夠將Android Studio降級到141.1903250版本,並且可以使用,但是我喜歡利用最新的Android Studio版本,因為它們不會破壞任何內容。
我做了兩件事來解決這個問題。 將groovy編譯添加到build.gradle文件中,並使用了較舊的gradle版本。
我將Project build.gradle文件更改為以下內容:
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()
}
}
我將模塊build.gradle文件更改如下:
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.+'
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.