Skip to content
Latchkey

Gradle "Cannot locate tasks ... is ambiguous" - Fix in CI

Gradle could not decide which task you meant. The name you passed (often an abbreviation, or one registered by two plugins) matches multiple tasks, so it refuses to guess.

What this error means

The invocation fails with Task 'check' is ambiguous in root project 'app'. Candidates are: 'checkstyleMain', 'checkstyleTest'. or a similar list. No task runs.

gradle
FAILURE: Build failed with an exception.

* What went wrong:
Cannot locate tasks that match 'test' as task 'test' is ambiguous in root
project 'app'. Candidates are: 'testClasses', 'testDebug', 'testRelease'.

Common causes

Name abbreviation matches several tasks

Gradle accepts camelCase abbreviations; a short name can expand to multiple real tasks.

Two plugins register the same task name

A custom task collides with a plugin-provided one of the same name in the same project.

A variant-aware plugin creates per-variant tasks

Android/flavor-style plugins create testDebug, testRelease, etc., so the bare test is ambiguous.

How to fix it

Use the fully qualified task path

Disambiguate by naming the exact task, optionally with its project path.

Terminal
./gradlew :app:checkstyleMain

Spell the full task name

Avoid abbreviations in CI scripts so the match is exact.

Terminal
./gradlew testRelease   # not the abbreviated 'test'

Rename a colliding custom task

If your own task clashes with a plugin task, give it a unique name.

gradle
tasks.register('appVerify') { /* was 'check' - now unique */ }

How to prevent it

  • Always use full, qualified task names in CI commands.
  • Avoid naming custom tasks the same as plugin tasks.
  • Run ./gradlew tasks to confirm the exact task names.

Frequently asked questions

What causes ""task name is ambiguous""?
Gradle accepts camelCase abbreviations; a short name can expand to multiple real tasks.
How do I fix "task name is ambiguous"?
Disambiguate by naming the exact task, optionally with its project path.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card