Mar*_*ler 97 android android-gradle-plugin deprecation-warning
我刚刚在库模块中注意到,该模块compileSdkVersion最近buildToolsVersion已被弃用。这是它抱怨的两种配置(删除文本)。目前这仅影响com.android.library,而不影响com.android.application:
plugins {
id "com.android.library"
}
android {
defaultConfig {
compileSdkVersion 31
buildToolsVersion "31.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
单击时,人们可能会注意到它com.android.build.gradle.AndroidConfig已被弃用BaseExtension(无论这对于匹配意味着什么build.gradle):
显然compileSdkVersion现在被称为compileSdk(这部分似乎有效)......并且buildToolsVersion必须被定义为属性。但是在构建时(不是我没有尝试过),属性buildToolsVerson = "31.0.0"是未知的:
android {
defaultConfig {
compileSdk 31
buildToolsVersion = "31.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
如何让它在没有弃用警告的情况下构建?
Mor*_*ori 73
如果您看到此错误,则“compileSdkVersion”已被弃用 对于新的 SDK 33:
apply plugin: 'com.android.application'
android {
// compileSdkVersion 33
defaultConfig {
compileSdk 33
}
...}
Run Code Online (Sandbox Code Playgroud)
Mar*_*ler 31
它的构建方式与此类似(需要更改库模块):
plugins {
id "com.android.application"
}
android {
defaultConfig {
compileSdkVersion 31
}
}
plugins {
id "com.android.library"
}
android {
defaultConfig {
// compileSdkVersion 31
compileSdk 31
}
}
Run Code Online (Sandbox Code Playgroud)
Her*_*uez 20
compileSdk 33
buildToolsVersion = '33.0.1'
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 kts gradle 文件 ( build.gradle.kts)
plugins {
id("com.android.library")
}
android {
defaultConfig {
// compileSdkVersion 31
compileSdk = 31
}
}
Run Code Online (Sandbox Code Playgroud)
apply plugin: 'com.android.application'
android {
defaultConfig {
buildToolsVersion = '30.0.3'
compileSdk = 31
}
}
Run Code Online (Sandbox Code Playgroud)
buildToolsVersion可以将其删除,因为不再需要它,并且compileSdkVersion 应该compileSdk根据 Google Android 自己的文档将其替换为 plain。
该函数已被弃用。被compileSdk取代
| 归档时间: |
|
| 查看次数: |
41478 次 |
| 最近记录: |