问题描述
我将gradle升级到4.1
I upgraded my gradle to 4.1
project.ext.set("currentGradleVersion", "4.1")
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
由于不赞成使用编译",因此我将所有编译"移至实现".还将variant.outputs.each更改为variants.outputs.all
I moved all the "compile" to "implementation" since "compile" is deprecated.Also changed variant.outputs.each to variants.outputs.all
apk生成的版本名称正确
The apk generates with the correct versionName
但是当我使用aapt命令"./aapt d Badging **.apk"时以下所有内容均返回为空,出了什么问题?
But when I used aapt command "./aapt d badging **.apk"All the below are returned as empty, what went wrong?
versionCode =''versionName =''platformBuildVersionName ="''
versionCode='' versionName='' platformBuildVersionName=''
推荐答案
经过一段时间……研究:
After some ... long.. researches :
以下是一些用于更新versionCode和versionName的解决方案:
Here are some solutions to update the versionCode and versionName:
简介:最新的gradle版本不再支持该功能.要解决此问题,您可以在当前代码中添加这段代码:
In a Brief :It is something no more supported by the latest gradle version.To fix it, you can ADD this piece of code in your current code :
applicationVariants.all { variant ->
...
variant.outputs.all { output ->
...
output.setVersionCodeOverride(VERSION_CODE_INTEGER)
output.setVersionNameOverride(VERSION_NAME_STRING)
...
}
...
}
}
这篇关于Gradle升级4.1不会加载versionCode和versionName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!