天天看點

Gradle Plugin 和 Gradle的版本的需求

分享一下我老師大神的人工智能教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實作我們中華民族偉大複興!

GradlePlugin 和Gradle的版本的需求

例如這裡如果plugin是2.3.0的那麼Gradle就至少是3.3的

參考官方網站,選擇合适的https://developer.android.com/studio/releases/gradle-plugin.html#updating-plugin

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+

參考: Androidgradle手動下載下傳(注意不是Android Gradle Plugin)

下載下傳位址就是這個:https://services.gradle.org/distributions/

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

#Mon Dec 28 10:00:20 PST 2015distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/distsdistributionUrl=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" target="_blank" rel="external nofollow" >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" target="_blank" rel="external nofollow" >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.

給我老師的人工智能教程打call!http://blog.csdn.net/jiangjunshow

Gradle Plugin 和 Gradle的版本的需求