https://kotlinlang.org logo
Title
j

Javier

06/23/2020, 9:30 AM
This is working for me
m

Manpreet Kunnath

06/23/2020, 9:42 AM
How do you use kapt in the dependency block? I still get an error when I use kapt("something"). kapt doesn't auto import. It needs importing. Is that the usual way?
s

Saurabh

06/23/2020, 10:25 AM
I use a different way of defining dependencies using kotlin dsl, it's not exactly the answer to your question. But I define them using extensions on DependencyHandler. You can check it out here https://github.com/sm3saurabh/RestaurantFinder/blob/dev/buildSrc/src/main/java/Dependencies.kt
By the way. Defining it like this also works for me
plugins {
    kotlin("kapt")
}

dependencies {
    kapt(DependencyString)
}
Which android studio version are you on?
m

Manpreet Kunnath

06/23/2020, 10:35 AM
Android Studio Canary 4.1
s

Saurabh

06/23/2020, 10:39 AM
After defining dependency with kapt, can you run ./gradlew tasks once.
That will give you more insights.
m

Manpreet Kunnath

06/23/2020, 10:41 AM
Okay, I'm looking into your repo and trying to make kapt work as you've written. I'll run ./gradlew tasks too now.
s

Saurabh

06/24/2020, 5:06 AM
Were you able to make it work?
m

Manpreet Kunnath

06/24/2020, 5:11 AM
I created a new project, followed your buildSrc structure for dependencies. And I added the hilt dagger plugin and I injected a variable and it worked. So using kapt in the way you suggested works. I'll provide the github link once I push the code for reference.
s

Saurabh

06/24/2020, 5:15 AM
I am glad that it worked out for you.
m

Manpreet Kunnath

06/24/2020, 5:16 AM
Thank you for your help