一、Gradle版本升级步骤
1、在gradle-wrapper.properties文件中修改distributionUrl的版本,
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
2、在工程里的build.gradle文件中的dependencies项里修改gradle版本,之后点 Try Again,
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/repo' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
...
}
}
二、错误集锦
1、Cannot set the value of read-only property ‘outputFile’ for ApkVariantOutputImpl_Decorated
错误原因:outputFile变成了可读字段
修改方案:
1、将variant.outputs.each中的each改成all
2、output.outputFile = new File(outputFile.parent, fileName)改为 outputFileName =fileName
原代码:
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile