我在一个 Android 应用程序项目中使用以下简化的配置。
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)
}
}
}
现在我将Gradle插件更新到v.0.13.0和Gradle到v.2.1,出现以下警告:
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脚本以消除弃用警告?
Could not find property 'file' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@4b50996.
这个Android Gradle插件真是太难用了。 - Merkdef file = output.outputFile
,那么属性 'file' 显然是不存在的。 - Thorbearjava.lang.RuntimeException: com.android.build.gradle.internal.crash.ExternalApiUsageException: groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property 'outputFile'
。目标API为30,Gradle插件版本为4.2.2,Gradle版本为6.9。 - Olcay Ertaş