【发布时间】:2019-11-23 09:33:18
【问题描述】:
同步 Gradle 时突然出现此错误:
警告:API 'variant.getJavaCompile()' 已过时且已被 替换为“variant.getJavaCompileProvider()”。 它将在 2019 年底被删除。 欲了解更多信息,请参阅https://d.android.com/r/tools/task-configuration-avoidance 受影响的模块: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 年底停止工作。关于它是什么以及如何解决它的任何想法?
【问题讨论】:
-
就像一个轻微的挑剔一样,警告不是错误。即使有警告,您的代码也应该以相同的方式编译,而错误会导致您的构建失败。只是提前通知,当前的做事方式将来可能无法正常工作,并且可能会通过插件更新来修复。你也抽时间read the page linked in the error吗?
-
我个人感觉是插件还没更新到使用新的Gradle API,应该及时修复。
标签: android android-studio compilation android-gradle-plugin google-fabric