由网友(野性稳江山)分享简介:我正在使用一个Android应用程序项目下面的简化配置。I am using the following simplified configuration in an Android application project.android {compileSdkVersion 20buildToolsVersion...
我正在使用一个Android应用程序项目下面的简化配置。
I am using the following simplified configuration in an Android application project.
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0.0"
applicationVariants.all { variant ->
def file = variant.outputFile
def fileName = file.name.replace(".apk", "-" + versionName + ".apk")
variant.outputFile = new File(file.parent, fileName)
}
}
}
现在,我更新了摇篮插件来v.0.13.0和摇篮到V.2.1。下面的警告出现:
Now that I updated the Gradle plug-in to v.0.13.0 and Gradle to v.2.1. the following warnings appear:
WARNING [Project: :MyApp] variant.getOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.setOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.getOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
WARNING [Project: :MyApp] variant.setOutputFile() is deprecated.
Call it on one of variant.getOutputs() instead.
我如何可以重写Groovy脚本摆脱德precation警告?
How can I rewrite the Groovy script to get rid of the deprecation warnings?
推荐答案
大厦从拉里·席费尔的答案你可以更改脚本是这样的:
Building on the answer from Larry Schiefer you can change the script to something like this:
android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
相关推荐
最新文章