Gradle "Plugin with id 'x' not found" - Fix Legacy apply plugin in CI
Gradle could not find a plugin applied the legacy way (apply plugin: 'x'). Unlike the modern plugins {} block, legacy apply resolves nothing on its own - the plugin jar must already be on the buildscript classpath, and here it is not.
What this error means
Configuration fails with Plugin with id '<id>' not found. This is the legacy-apply form of the error; the plugins {} block instead says "was not found in any of the following sources".
* What went wrong:
A problem occurred evaluating root project 'app'.
> Plugin with id 'com.example.custom' not found.Common causes
No buildscript classpath dependency for the plugin
apply plugin: 'x' does not download anything. If the plugin jar is not declared in a buildscript { dependencies { classpath ... } } block (or applied via plugins {}), Gradle cannot find the id.
Wrong plugin id
The applied id must match the plugin’s registered id exactly. A typo or using the artifact name instead of the plugin id leaves it unresolved.
How to fix it
Prefer the plugins {} block
Apply and resolve the plugin in one place so Gradle fetches it from the configured plugin repositories.
plugins {
id("com.example.custom") version "1.2.0"
}Or add the buildscript classpath for legacy apply
If you must use legacy apply, declare the plugin jar on the buildscript classpath first.
buildscript {
repositories { gradlePluginPortal() }
dependencies { classpath("com.example:custom-gradle-plugin:1.2.0") }
}
apply(plugin = "com.example.custom")How to prevent it
- Use the
plugins {}block, which resolves and applies in one step. - Declare plugin repositories in
pluginManagementin settings.gradle. - Use the exact registered plugin id, not the artifact name.