转发请注明://www.greatytc.com/p/adbdea069190
gradle 不爽的地方:
- 每次github上下载一个开源android工程,都要改一遍gradle,如果不改,99%编不过,然后下载一上午不见得能成功。
- 不敢轻易更新gradle以及gradle插件的版本,一旦更新,项目组遭殃了,除非你拿着U盘挨个把你本地的文件拷给他们,不然你就要做好挨骂的准备吧。我本地的gradle版本已经有一年没更新过了,现在插件版本还是用的3.0.1,gradle版本是4.1
为了不再忍受下去,自立更生!!!
第一步很多人已经这样用了,第二步没搜到过。
第一步 build.gradle
首先看project的build.gradle,添加阿里云的仓库,极速下载
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
ext.lifecycle_version = '1.1.1'
repositories {
// google()
// jcenter()
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }
}
allprojects {
repositories {
// google()
// jcenter()
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
第二步 gradle-wrapper.properties
该步找遍全网,要么先把bin下载下来的离线模式,要么就是本地搭建个下载服务器,感觉违背了gradle的思想。
我把这两步结合起来,用有道云笔记生成了一个可下载的文件链接
这个地址对应的gradle版本是:
gradle-5.5-bin.zip
http://note.youdao.com/yws/public/resource/c04d42c2fbcf86f9b956bfd3acb1434a/xmlnote/330841CC9FC74981A514B9D32F5A2A6C/3322
所以我的gradle-wrapper.properties文件就变成了如下这种
#Mon Apr 08 11:54:12 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=http://note.youdao.com/yws/public/resource/c04d42c2fbcf86f9b956bfd3acb1434a/xmlnote/330841CC9FC74981A514B9D32F5A2A6C/3322