1. 程式人生 > >Gradle Plugin 和 Gradle的版本的需求

Gradle Plugin 和 Gradle的版本的需求

GradlePlugin Gradle的版本的需求

例如這裡如果plugin2.3.0的那麼Gradle 就至少是3.3

Plugin version

Required Gradle version

1.0.0 - 1.1.3

2.2.1 - 2.3

1.2.0 - 1.3.1

2.2.1 - 2.9

1.5.0

2.2.1 - 2.13

2.0.0 - 2.1.2

2.10 - 2.13

2.1.3 - 2.2.3

2.14.1+

2.3.0+

3.3+

如果工程\gradle\wrapper\gradle-wrapper.properties中配置如下:

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

則工程\build.gradle下的檔案內容如下:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    
} } allprojects {     repositories {         jcenter()     } } task clean(type: Delete) {     delete rootProject.buildDir }

也就是這個gradle客戶端外掛的版本需要與gradle的版本對應起來,這裡外掛版本使用的是2.3.3對應的gradle版本就是3.3.如果不對應則會提示出下錯誤:

Error:Unable to find method'com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V'.

Possible causes for this unexpected errorinclude:<ul><li>Gradle's dependency cache may be corrupt (thissometimes occurs after a network connection timeout.)

<ahref="syncProject">Re-download dependencies and sync project(requires network)</a></li><li>The state of a Gradle buildprocess (daemon) may be corrupt. Stopping all Gradle daemons may solve thisproblem.

<ahref="stopGradleDaemons">Stop Gradle build processes (requiresrestart)</a></li><li>Your project may be using a third-partyplugin which is not compatible with the other plugins in the project or theversion of Gradle requested by the project.</li></ul>In the case ofcorrupt Gradle processes, you can also try closing the IDE and then killing allJava processes.