默认包是xxx-debug.aar
或xxx-release.aar
,是否可以生成类似xxx-v0.12-release.aar
的包名?
答案 0 :(得分:1)
我正在使用Gradle 5+,这对我有用
libraryVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = "my-lib-${variant.name}-v${defaultConfig.versionCode}(${defaultConfig.versionName}).aar"
}
}
输出将为
my-lib-release-v5(0.0.4).aar
答案 1 :(得分:0)
您可以使用libraryVariants
块并执行以下操作。
defaultConfig {
...
versionCode xx
versionName "yy.zz"
}
buildTypes {
release {
...
android {
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = outputFile.name.replace("${variant.name}.aar",
"v${defaultConfig.versionName}-${variant.name}.aar")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
}
答案 2 :(得分:0)
试试这个:
android {
compileSdkVersion ...
defaultConfig {
minSdkVersion ...
targetSdkVersion ...
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
...
}
}
android.libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${variant.name}-${defaultConfig.versionName}.aar"
}
}
}
}
不要忘记重建您的项目(Build-> Rebuild Project)
输出将如下:
yourModuleName-调试0.0.1.aar