2

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

Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Tried all the following ways :

  1. tried This link
  2. Tried This link as well

Please help to solve this problem

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}
Community
  • 1
  • 1
John
  • 1,407
  • 7
  • 26
  • 51

2 Answers2

1

I had the same issue with one of my projects. I dropped the gradle version back a minor version and it resolved the issue for me.

classpath 'com.android.tools.build:gradle:2.1.0'
Bret
  • 31
  • 3
0

Try removing dexguard & its related entries, Keep minifyEnabled as false & remove related entries, i.e.proguardFile getDefaultDexGuardFile('dexguard-release.pro')

Arunjyothis
  • 1,426
  • 1
  • 10
  • 11