Gradle warns that Project.getConvention() has been deprecated
Project.getConvention() method has been deprecatedShort answer
Gradle deprecated Project.getConvention() and the Convention type because extensions replace them. A build script that reads a convention, or a plugin built for Gradle 8.1 or older, triggers the warning. Find the source with --warning-mode=all, then use the extension blocks (java, base, application) or update the plugin.
Fix it fast
1Find out which cause you have
Run any task with every warning logged, so Gradle prints where the deprecated call comes from instead of only a summary at the end.
./gradlew help --warning-mode=all2Match what you see, then jump to its fix
What does the error look like?
Project.getConvention() method has been deprecatedThis is scheduled to be removed in Gradle 9.0
Cause 1 of 2
Your own build script reads conventions or uses the old Kotlin DSL helpers
1Check
Look for code that touches project.convention, or the Kotlin DSL helpers the<T>() and configure<T> on a core plugin.
grep -rnE "convention|the<|configure<" build.gradle* app/build.gradle* buildSrc 2>/dev/null2Fix
Use the extension blocks instead: java { }, base { } and application { }. For war, ear and project-report, configure the task directly. If you need the typed lookup, extensions.getByType works.
// Kotlin DSL
java {
sourceCompatibility = JavaVersion.VERSION_17
}
val javaExt = extensions.getByType<JavaPluginExtension>()3Verify
Run the build again with all warnings on and confirm the deprecation is gone.
./gradlew help --warning-mode=allConfirmed by docs.gradle.org
Cause 2 of 2
A plugin built for Gradle 8.1 or older still uses conventions
1Check
Gradle notes that a plugin compiled with Gradle 8.1 or earlier can hit this through the<T>() or configure<T> in the Kotlin DSL. Note which plugin the trace names and its version.
./gradlew buildEnvironment2Fix
Update that plugin to a release built with Gradle 8.2 or later. If it is your own plugin, recompile it with 8.2 or later, or use extensions.getByType<T>().
plugins {
id("com.example.plugin") version "NEW_VERSION"
}3Verify
Re-run with warnings enabled. The warning should no longer name that plugin.
./gradlew help --warning-mode=allConfirmed by docs.gradle.org
How do I stop it coming back?
- Run CI builds with --warning-mode=all once a week so deprecations show up before an upgrade.
- Upgrade plugins together with Gradle, not after the build breaks.
- Configure core plugins through their extension blocks only.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix