Maaz Zindani

Loading the index…

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

Gradle rejects the dependencyResolutionManagement block in a build script

Your error

Could not find method dependencyResolutionManagement() for arguments [build_..._run_closure3@...] on project ':app' of type org.gradle.api.Project.1 more line it can show

Fix it fast

Most common cause, 1 of 2

The block sits in build.gradle instead of settings.gradle

Cut the block out of the build script and paste it into settings.gradle(.kts) in the root folder, as in the Android template.

Fix
// settings.gradle.kts
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "My Application"
include(":app")
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Could not find method dependencyResolutionManagement() for arguments [...] on project ':app' means the block was put in a build.gradle file, where the Project API has no such method. It is part of the Settings API in settings.gradle(.kts), available since Gradle 6.8. Move it there, and update any wrapper older than 6.8. Gradle 6.8 to 9.9.2.

  • Applies to Gradle 6.8 to 9.9.2, Android Gradle plugin 8.x to 9.5.2, Groovy and Kotlin DSL
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Find every file that holds the block and check the Gradle version of the wrapper. A hit in any build.gradle file points to the first cause; a hit only in settings.gradle with a wrapper below 6.8 points to the second.

Run this first
grep -rn "dependencyResolutionManagement" --include="*.gradle" --include="*.gradle.kts" .
./gradlew --version

Then find the line you see in this list and open its fix:

  1. 1The block sits in build.gradle instead of settings.gradleThe message ends with on project ':app' or on root project, of type org.gradle.api.Project
  2. 2The Gradle wrapper is older than 6.8The block is already in settings.gradle, the message does not mention a project, and ./gradlew --version prints a release below 6.8

What does the error look like?

  • Could not find method dependencyResolutionManagement() for arguments [build_..._run_closure3@...] on project ':app' of type org.gradle.api.Project.
  • Could not find method dependencyResolutionManagement() for arguments

Cause 1 of 2

The block sits in build.gradle instead of settings.gradle

You seeThe message ends with on project ':app' or on root project, of type org.gradle.api.Project

Check

Could not find method dependencyResolutionManagement() on a project means Gradle evaluated the block inside a build script. Gradle looks up an unknown block as a method of the object that runs the script, and only the Settings object, which runs settings.gradle(.kts), has dependencyResolutionManagement. A snippet copied without its file name can end up in app/build.gradle, or in the root build.gradle next to an old allprojects { repositories } block.

Check
grep -n -A6 "dependencyResolutionManagement" build.gradle* app/build.gradle*

Fix

Cut the block out of the build script and paste it into settings.gradle(.kts) in the root folder, as in the Android template. Then remove the duplicate repositories from allprojects in the root build.gradle. With FAIL_ON_PROJECT_REPOS, any repository left in a build file becomes a build error.

Fix
// settings.gradle.kts
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "My Application"
include(":app")

Verify

The project configures and resolves its dependencies from the repositories declared in settings.

Verify
./gradlew :app:dependencies --configuration debugRuntimeClasspath

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 2

The Gradle wrapper is older than 6.8

You seeThe block is already in settings.gradle, the message does not mention a project, and ./gradlew --version prints a release below 6.8

Check

Central declaration of repositories arrived in Gradle 6.8, so an older wrapper has no dependencyResolutionManagement on Settings either. This shows up when a block from current documentation is copied into a project that still runs an old wrapper.

Check
grep distributionUrl gradle/wrapper/gradle-wrapper.properties

Fix

Either remove the block and keep the per-project repositories that old Gradle understands, or upgrade the wrapper together with the Android Gradle plugin. Gradle 9 works only with AGP 8.4.0 or later, while AGP 9.5 asks for at least Gradle 9.6.0, so choose the pair from the AGP compatibility table.

Fix
./gradlew :wrapper --gradle-version 9.9.2

Verify

./gradlew --version reports the new release, and the settings file configures without the error.

Verify
./gradlew --version
./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Declare library repositories only in settings.gradle(.kts) with repositoriesMode FAIL_ON_PROJECT_REPOS; a repository pasted into a module then breaks the build at once with a clear message.
  • When copying a Gradle snippet, note which file it belongs to: pluginManagement, dependencyResolutionManagement, rootProject.name and include live in settings, plugins and dependencies in module build files.
  • Upgrade the wrapper with ./gradlew :wrapper --gradle-version and commit gradle-wrapper.properties, so every machine and CI agent runs the Gradle release the build files are written for.

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 on the same stack: QistLock, Nuclear Home Video, Dispatch Pro.

Next step

Want this handled for good?

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