Gradle "Could not create task ... of type" - Fix Plugin/DSL in CI
Gradle could not instantiate a task because its type is unavailable or misconfigured. Usually the plugin that defines the task type was not applied, or a required constructor argument/property is missing.
What this error means
Configuration fails with Could not create task ':app:myTask' of type 'com.example.MyTask', naming the task and type. The build stops during configuration.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:generateDocs' of type 'com.example.DocsTask'.
> Could not find a public constructor for type DocsTask.Common causes
Plugin defining the task type not applied
Registering a task of a plugin-provided type without applying that plugin means the type is not on the classpath at configuration time.
Invalid task constructor or property
A custom task type missing an injectable constructor, or a required property left unset, prevents Gradle from instantiating it.
How to fix it
Apply the plugin that provides the task type
Apply the plugin so its task types are available before you register them.
plugins {
id("com.example.docs") version "1.2.0"
}Fix the task registration
Register with the correct type and supply required configuration.
tasks.register<com.example.DocsTask>("generateDocs") {
inputDir.set(layout.projectDirectory.dir("docs"))
}How to prevent it
- Apply the plugins that define custom task types, register tasks with
register<Type>(...), and set all required task properties.