Android Studio gradle会出现如下错误:
错误:(36,0)原因:org / codehaus / groovy / runtime / StringGroovyMethods 打开文件
Haven能够为最新版本的Android Studio Canary版本解决此问题。我添加了
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
到Project:build.gradle,我仍然有一个问题,似乎有一些兼容性问题,但不知道是什么。
这是我的一些版本信息:
AI-141.2071668(最新的金丝雀版)
插件
Android支持版:10.1.3 RC 1
Groovy版本:9.0
爪哇:
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版本,当他们不打破任何东西。
答案 0 :(得分:-1)
我做了两件事来解决这个问题。将groovy编译添加到build.gradle文件并使用旧版本的gradle。
我将Project build.gradle文件更改为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()
}
}
我更改了模块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.+'
}
}