The answer by @nongthonbam-tonthoi is correct but he does not explain why.
Short version
Implementation - hide this dependency from other modules(that depend on this module). if B
depends on A
, it cannot use any dep declared in A
using implementation
.
api - Make this available to other modules that depend on this module.i.e if you add say GSON as a dep in module A
using api
rather than implementation
, all other modules that depend A
can use GSON without declaring it again.
Long version
implementation
is a way of declaring dependencies for only a given module. What this means is that, the dependency can only be used in that particular module. compile
on the other hand "leaks" the dependencies to other modules so you can import and use the classes that dep brings in other modules. If you want this behavior, the new way of doing it is to use api
.
This change is particularly targeted at multi-module projects as it can help gradle avoid re-compiling a module during a build when it does not change.
However if you're migrating from an old project, chances are you are (ab)using compile to use dependencies declared in other modules without explicitly declaring them again.
You can keep using compile
but remember that it's is deprecated and will be removed soon.
See here for a deeper explanation.