Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle warns that Project.getConvention() has been deprecated

ErrorProject.getConvention() method has been deprecated

Short 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.

  • Applies to Gradle 8.x, Gradle 9, Android Gradle Plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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=all
  2. 2Match what you see, then jump to its fix

    1. 1The stack trace points at build.gradle(.kts) in your projectYour own build script reads conventions or uses the old Kotlin DSL helpersFix
    2. 2The stack trace names a plugin class, not your scriptA plugin built for Gradle 8.1 or older still uses conventionsFix

What does the error look like?

  • Project.getConvention() method has been deprecated
  • This 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/null

2Fix

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=all

Confirmed by docs.gradle.org

Did this fix it?

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 buildEnvironment

2Fix

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=all

Confirmed by docs.gradle.org

Did this fix it?

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

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 fix

Mobile 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.