我已更新到 AndroidStudio 3.3,它现在会发出有关已弃用库的警告:
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance. To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Affected Modules: app
他们的网站上提供了更多信息:
但我并不完全理解它。他们说:
To see the additional info, you need to include the following in your project's gradle.properties file:
android.debug.obsoleteApi=true
所以我拿了标有 (Project: [my project]) 的 build.gradle
文档如下所示:
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
mavenCentral()
}
}
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin" == plugin.class.name) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin" == plugin.class.name) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
repositories {
mavenCentral()
}
但是,我不明白,我现在应该在哪里添加该行。而且无论我把它放在哪里,我总是会出错。
例如直接写在第一行的时候:
Could not get unknown property 'android' for root project [my project] of type org.gradle.api.Project.
那么应该在哪里添加呢?还是我混合了 gradle 文件的“项目”和“应用程序”的定义?
最佳答案
你需要把它放到 gradle.properties
文件中code> 文件,您当前正在尝试执行此操作。
来自 android 开发者文档
Better debug info when using obsolete API: When the plugin detects that you're using an API that's no longer supported, it can now provide more-detailed information to help you determine where that API is being used. To see the additional info, you need to include the following in your project's gradle.properties file:
android.debug.obsoleteApi=true
You can also enable the flag by passing -Pandroid.debug.obsoleteApi=true from the command line.
您可以查看 Link .
关于Android Gradle - 在哪里添加 "android.debug.obsoleteApi=true",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54198773/