After updating to Android Studio 3.0 and creating a new project, I noticed that in build.gradle
there is a new way to add new dependencies instead of comp
Gradle 3.0
introduced next changes:
compile
-> api
api
keyword is the same as deprecated compile
compile
-> implementation
Is preferable way because has some advantages. implementation
expose dependency only for one level up at build time (the dependency is available at runtime). As a result you have a faster build(no need to recompile consumers which are higher then 1 level up)
provided
-> compileOnly
This dependency is available only in compile time(the dependency is not available at runtime). This dependency can not be transitive and be .aar
. It can be used with compile time annotation processor and allows you to reduce a final output file
compile
-> annotationProcessor
Very similar to compileOnly
but also guarantees that transitive dependency are not visible for consumer
apk
-> runtimeOnly
Dependency is not available in compile time but available at runtime.
[POM dependency type]