在构建我的 Android 应用程序项目时,我开始收到此警告:
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.2/userguide/upgrading_version_8.html#java_convention_deprecation
at org.gradle.api.plugins.internal.NaggingJavaPluginConvention.logDeprecation(NaggingJavaPluginConvention.java:185)
我的应用程序等级:
plugins {
id 'com.android.application'
}
android {
namespace 'myapp'
compileSdk 34
defaultConfig {
applicationId "myapp"
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation "androidx.preference:preference:1.2.1"
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
和项目gradle:
plugins {
id 'com.android.application' version '8.2.2' apply false
}
从警告中链接的文档中我读到:
约定的概念已经过时,并被提供自定义 DSL 的扩展所取代。
他们想用扩展取代一些约定。
有一个例子:
plugins {
id 'java'
}
sourceCompatibility = 18 // Accessing a convention
替换为:
plugins {
id 'java'
}
java {
sourceCompatibility = JavaVersion.VERSION_18
}
但是我的 gradle 中没有插件 id 'java',我绝对不知道应该在 gradle 中替换什么以避免此警告(未来 gradle 中的错误)。
随机开始一一删除依赖,当我删除picasso依赖时,就不再有警告了