其他分享
首页 > 其他分享> > WARNING: API 'variantOutput.getPackageApplication()' is obsolete and has been replaced wit

WARNING: API 'variantOutput.getPackageApplication()' is obsolete and has been replaced wit

作者:互联网

WARNING: API 'variantOutput.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.

将代码

applicationVariants.all { variant ->
if (variant.buildType.name.equals('release')) {
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "Terminator${defaultConfig.versionName}.apk"
}
}
} else if (variant.buildType.name.equals('debug')) {
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
outputFileName = "Terminator${defaultConfig.versionName}${versionNameSuffix}.apk"
}
}
}
}

改为

applicationVariants.all { variant ->
if (variant.buildType.name.equals('release')) {
variant.outputs.all { output ->
outputFileName = "Terminator${variant.versionName}_${releaseTime()}.apk"
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// outputFileName = "Terminator${defaultConfig.versionName}.apk"
// }
}
} else if (variant.buildType.name.equals('debug')) {
variant.outputs.all { output ->
outputFileName = "Terminator${variant.versionName}_${releaseTime()}.apk"
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// outputFileName = "Terminator${defaultConfig.versionName}${versionNameSuffix}.apk"
// }
}
}
}

标签:getPackageApplicationProvider,outputFile,name,getPackageApplication,variant,apk,
来源: https://www.cnblogs.com/dongweiq/p/12370851.html