简体   繁体   中英

Unable to apply plugin: 'dexguard' at build.gradle file

I've below error when I add apply plugin: 'dexguard' into my main module's build.gradle file.

Error:Unable to load class 'com.android.build.gradle.BasePlugin$PostCompilationData'. Possible causes for this unexpected error include:

  • You are using JDK version 'java version "1.7.0_67"'. Some versions of JDK 1.7 (eg 1.7.0_10) may cause class loading errors in Gradle. Please update to a newer version (eg 1.7.0_67). Open JDK Settings
  • 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.

MY project's build.gradle file:

buildscript {
    repositories {
        flatDir dirs: 'C:/Users/devrimtu/Documents/Programs/DexGuard/DexGuard6.1/lib'
        jcenter()
    }
    dependencies {
        classpath ':dexguard'
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

My main module's build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'dexguard'

android {
 ..
    buildTypes {
        debug {
            proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
            proguardFile 'dexguard-project.txt'
            proguardFile 'proguard-project.txt'
        }
        release {
            proguardFile getDefaultDexGuardFile('dexguard-release.pro')
            proguardFile 'dexguard-project.txt'
            proguardFile 'proguard-project.txt'
        }
    }
}

NOTE: If I remove apply plugin: 'dexguard' line, error becomes:

Error:(29, 0) Gradle DSL method not found: 'getDefaultDexGuardFile()' Possible causes:

  • The project 'AndroidWorkSpace' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin

Extras:

  • I've DexGuard v6.1 . And the flatDir dirs at build.gradle file is the correct location.
  • Android Studio v 1.3.0 (build 141.2117773)
  • Gradle under Android Studio installation dir gradle-2.4
  • 将DexGuard更新到7.0.18版后,问题得以解决。

    The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM