无法应用插件:'dexguard' 在 build.gradle 文件
Unable to apply plugin: 'dexguard' at build.gradle file
当我将 apply plugin: 'dexguard'
添加到主模块的 build.gradle 文件时出现以下错误。
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 (e.g.
1.7.0_10) may cause class loading errors in Gradle. Please update to a newer version (e.g. 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.
我的项目的build.gradle文件:
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'
}
}
我的主模块的 build.gradle 文件:
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'
}
}
}
注意: 如果我删除 apply plugin: 'dexguard'
行,错误变为:
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
额外内容:
我 DexGuard v6.1
。 build.gradle
文件中的 flatDir dirs
是正确的位置。
Android工作室v 1.3.0 (build 141.2117773)
Gradle 在 Android Studio 安装目录下 gradle-2.4
将DexGuard升级到7.0.18版本后问题解决
当我将 apply plugin: 'dexguard'
添加到主模块的 build.gradle 文件时出现以下错误。
Error:Unable to load class 'com.android.build.gradle.BasePlugin$PostCompilationData'. Possible causes for this unexpected error include:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- You are using JDK version 'java version "1.7.0_67"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle. Please update to a newer version (e.g. 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.
我的项目的build.gradle文件:
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'
}
}
我的主模块的 build.gradle 文件:
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'
}
}
}
注意: 如果我删除 apply plugin: 'dexguard'
行,错误变为:
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
额外内容:
DexGuard v6.1
。 build.gradle
文件中的 flatDir dirs
是正确的位置。v 1.3.0 (build 141.2117773)
gradle-2.4
将DexGuard升级到7.0.18版本后问题解决