3

What is the difference between kapt and implementation in Gradle when declaring dependencies and when should one be used over another?

Example:

//Room Components
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"

// dagger
implementation "com.google.dagger:dagger:$rootProject.ext.daggerVersion"
kapt "com.google.dagger:dagger-android processor:$rootProject.ext.daggerVersion"
Hafez Divandari
  • 6,148
  • 4
  • 32
  • 54
user3189761
  • 131
  • 2
  • 6
  • `kapt` and `implementation` are not analogous. [1](https://stackoverflow.com/questions/47224294/can-i-use-compileonly-as-a-replacement-for-annotationprocessor-in-gradle) [2](https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-and-compile-in-gradle) [3](https://stackoverflow.com/questions/44413952/gradle-implementation-vs-api-configuration) [4](https://stackoverflow.com/questions/50027741/android-project-with-java-and-kotlin-files-kapt-or-annotationprocessor) – denvercoder9 May 14 '20 at 09:37

1 Answers1

0

In short: implementation and kapt are not related directly

When it comes to kotlin, you use kapt where Java uses annotationProcessor.

Which one to use? Depends on how the lib works

Check it out

https://developer.android.com/studio/build/dependencies?hl=pt-br