我正在尝试使用以下代码自定义构建过程
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;
}
}
}
}
关于android - 错误 :(81, 0) 不再支持 getMainOutputFile。如果需要确定输出的文件名,请使用 getOutputFileName。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44516023/