我正在尝试使用以下代码自定义生成过程
android.applicationVariants.all { variant ->
def appName = "MyApplication.apk"
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent, appName)
}
}
但从android studio 3.0来看,它不起作用,我的错误如下
错误:(81,0)不再支持GetMainOutputFile。如果需要确定输出的文件名,请使用getoutputfilename。
最佳答案
就这样做:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
android.applicationVariants.all { variant ->
def date = new Date();
def formattedDate = date.format('dd MMMM yyyy')
variant.outputs.all {
def newApkName
newApkName = "MyApp-${variant.versionName}, ${formattedDate}.apk"
outputFileName = newApkName;
}
}
}
}