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 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.