我已经把Android Studio更新到了最新版本:Android Studio 2.2 Preview 1
  
  它支持JDK 1.8(java 8)
  
  更新工作室后出现以下构建错误


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版本不兼容的第三方插件。尝试关闭IDE,然后终止所有Java进程。


  尝试了以下所有方法:
  
  
  尝试This link
  尝试This link as well
  


请帮忙解决这个问题


  将添加我的build.gradle文件


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'`



  顶级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'

07-24 09:47
查看更多