Why is gradle complaining about api and implementation?

Learn
1 min readMar 24, 2024

So, I was copying relevant subprojects from a gradle project to my project. On build, gradle complains unknown method api . I thought let me try changing that to implementation and it says unknown method implementation

These are basic gradle abstractions in my mind to represent how the particular library needs to be used in the project.

And gradle does not even recognize these?

java-library plugin. This is the plugin that includes api and implementation and other such dependency semantics. And this needed to be included in the project. It does not come by default in gradle even while it is very typically used. api and implementation are so typical that you would think they are packaged with gradle but they are not.

Also, just including the java-library plugin is NOT enough. You need to apply the plugin as well.

In your projects build.gradle file, you call a method subprojects and in that method, you apply the java-library plugin. Now, you will be on to the next error in your journey.

subprojects {
apply plugin `java-library`
}

Above is just reference syntax. Hope you get the idea here.

--

--