我刚刚注意到在一个库模块中,
显然,
如何在构建时避免出现弃用警告?
compileSdkVersion
和buildToolsVersion
最近已经被弃用。这是两个配置,它对此进行了抱怨(删除线文本)。目前这只影响com.android.library
,而不是com.android.application
。plugins {
id "com.android.library"
}
android {
defaultConfig {
compileSdkVersion 31
buildToolsVersion "31.0.0"
}
}
点击进去后,你可能会注意到com.android.build.gradle.AndroidConfig
已经被BaseExtension
取代(不管对于匹配的build.gradle
意味着什么):
显然,
compileSdkVersion
现在被称为compileSdk
(这部分似乎有效)...而buildToolsVersion
必须被定义为一个属性。但是在构建时(我并不是没有尝试过),属性buildToolsVerson = "31.0.0"
是未知的。android {
defaultConfig {
compileSdk 31
buildToolsVersion = "31.0.0"
}
}
如何在构建时避免出现弃用警告?
buildToolsVersion = '30.0.3'
,因为根据文档:如果你使用的是 Gradle 3.0.0 或更高版本的 Android 插件,你的项目会自动使用插件指定的默认构建工具版本。 - Amc