When to use api over implementation.

I enjoy all things Mobile and Software Engineering. I am currently a Software Engineer and Android Google Developer Expert based in Germany 🇩🇪 but from Kenya 🇰🇪, whose primary focus has been Mobile for the past 6 years.
I share my experiences, the good, the bad, the ugly, and sometimes random tech talks :)
Recently on my android adventures, I decided to split up a project at work into modules and make my life simpler😃.
One of my modules is a themes module that cuts across all modules providing the necessary themes, styles and colours to other components, but creating the module and implementing it in other modules as shown didn't serve me as I had expected.
dependencies{
implementation project(':themes')
}

This was because my themes module was using the material design library which was not implemented in the other modules.
themes module build.gradle
So the next logical option might have been to go onto each module and implement the material design library above over and over again but this seemed extremely redundant.
Where api comes in...
From the Gradle documentation:
The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.
Therefore in my case, I need to make the material design library accessible across my modules by just adding the themes module, and this is done simply by changing the implementation keyword to api as shown below and voila..its done🥳




