I have updated the android studio to latest version : android studio 2.2 preview 1
it supports JDK 1.8(java 8)
after updating the studio getting following build error
Cause: com.android.build.gradle.AppPlugin cannot be cast to groovy.lang.GroovyObject
Error:Cause: com.android.build.gradle.AppPlugin cannot be cast to groovy.lang.GroovyObject
此意外错误的可能原因包括:
- Gradle 的依赖项缓存可能已损坏(这有时会在网络连接超时后发生。) 重新下载依赖项并同步项目(需要网络)
- Gradle 构建过程(守护进程)的状态可能已损坏。停止所有 Gradle 守护进程可能会解决此问题。 停止 Gradle 构建过程(需要重新启动)
- 您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的 Gradle 版本不兼容。
Tried all the following ways :
- tried This link
- Tried This link as well
请帮忙解决这个问题
Will be adding my build.gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs '/usr/local/DexGuard-7.0.22/lib' }
mavenCentral() // For the Android plugin.
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath ':dexguard:'
}}`apply plugin: 'com.android.application'
apply plugin: 'dexguard'
apply plugin: 'io.fabric'
afterEvaluate { project ->
tasks['dexguardRelease'].enabled = true
}repositories {
maven { url 'https://maven.fabric.io/public' }
}android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId 'com.package.name'
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0.1"
useLibrary 'org.apache.http.legacy'
}
productFlavors {
}
buildTypes {
debug {
minifyEnabled false
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.txt'
//proguardFile 'proguard-project.txt'
}
release {
minifyEnabled true
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
//proguardFile 'proguard-project.txt'
}}}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.google.android.gms:play-services-auth:9.0.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services-maps:9.9.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'}apply plugin: 'com.google.gms.google-services'`
Top level gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}}allprojects {
repositories {
jcenter()
}}task clean(type: Delete) {
delete rootProject.buildDir}
最佳答案
我的一个项目也遇到了同样的问题。我将 gradle 版本降回次要版本,它为我解决了这个问题。
classpath 'com.android.tools.build:gradle:2.1.0'
关于Android studio 更新构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37406621/