Android Stduio自从发布以来,Gradle就是一个绕不开的“坑”。
因为Gradle的版本有很多。同时每个Gradle适配的插件的版本数字和Gradle本身的版本是不一样的。
还有配置文件中需要修改某些地方。
设置成功的项目是如何样子的呢?
布局文件中是可以预览到真正的布局的。
我们今天介绍一个正确的配置。
1:设置里面是这个样子的。
顺带解释下,就是说我选用的是gradle-2.6-all.bin
这个一般下载的话,都是非常拧巴的。除非你购买了FQ软件。FQ是啥?我就不说了。涉及敏感推销嫌疑。
然后我们把gradle-2.6-all.bin放在C盘下面的目录下面,不清楚的就看上面这个截图中的目录。
2:build.gradle里面是这样子设置的。
为了方便查看,源代码全部贴出来。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
注意关键的地方是: classpath "com.android.tools.build:gradle:4.1.1"
3.gradle-wrapper.properties这个文件里面是这样子的。
#Tue Dec 22 11:43:17 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
Good Lucky!
举报/反馈