Tag Archives: Could not find method api() for arguments….

[Solved] Gradle Error: Could not find method api() for arguments….

The compile keyword for dependency is introduced into gradle for old projects. After upgrading gradle version 7. X, this keyword is enabled.

After checking the documentation, if the jar package of the project is to be exposed, use API. If the referenced jar package is only used by the project, use implementation.

Core, the jar package reference of the public module is changed to API, but an error is reported

A problem occurred evaluating project ':inkyi-common'.
> Could not find method api() for arguments [org.springframework.boot:spring-boot-starter-web:2.6.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

That means: without API, Baidu has said to upgrade gradle 3. X for a long time. Isn’t that bullshit

After reading the official website, the first sentence gives the answer: API belongs to the method in Java library

Put the in build.gradle

plugins {
    id 'java'
}

Change to

plugins {
    id 'java-library'
}

Just do it.