同步 Gradle 时突然出现此错误:
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance Affected Modules: app
我有这个应用模块的 build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "..."
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionNameSuffix = version_suffix
[...]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
[...]
}
debug {
[...]
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.android.support:preference-v7:28.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.google.android.material:material:1.0.0-rc02'
[...]
}
我可以正确编译应用程序,但有点麻烦,而且我认为,某些东西将在 2019 年底停止工作。关于它是什么以及如何解决它的任何想法?
最佳答案
更新到 3.3.0 后我遇到了这个问题
如果您没有执行 gradle 文件中的错误状态,则可能是某些插件仍未更新到较新的 API 导致此问题。要找出它是哪个插件,请执行以下操作(如 "Better debug info when using obsolete API" of 3.3.0 announcement 中所述):
- 将 'android.debug.obsoleteApi=true' 添加到您的 gradle.properties 文件中,该文件将记录错误并提供更多详细信息
- 重试并阅读日志详细信息。会有一丝“有问题”的插件
- 确定后,尝试禁用它并查看问题是否消失,以确保
- 转到插件的 github 页面并创建包含详细日志和清晰描述的问题,以便您帮助开发人员更快地为每个人修复它
- 在他们修复它时耐心等待,或者你修复它并为开发者创建 PR
希望对他人有所帮助
关于android - 警告 : API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52470044/