Reputation: 61
I have implemented Hilt dependencies in my project, but when I need the @Inject annotation for my constructor, it's not working. basically when I tried to import it manually i found out, the inject folder inside javax is empty. So the structure is like javax.inject. And after that I get nothing as the inject folder is empty. I have tried rebuilding and cleaning he project. I also tried by Invalidating caches but nothing seems to work. How can I make this work ?
Dependencies List
dependencies {
implementation(project(":shared"))
implementation(AndroidX.appCompat)
implementation(Compose.runtime)
implementation(Compose.runtimeLiveData)
implementation(Compose.ui)
implementation(Compose.material)
implementation(Compose.uiTooling)
implementation(Compose.foundation)
implementation(Compose.compiler)
implementation(Compose.constraintLayout)
implementation(Compose.activity)
implementation(Compose.navigation)
implementation(Google.material)
implementation(Hilt.hiltAndroid)
implementation(Hilt.hiltNavigation)
kapt(Hilt.hiltCompiler)
implementation(Kotlinx.datetime)
debugImplementation(SquareUp.leakCanary)
}
Hilt version - 2.37
Upvotes: 5
Views: 2135
Reputation: 1328
Make sure you're annotating with the @Inject (uppercase I) and not @inject with a lowercase i.
Upvotes: 0
Reputation: 5236
If your javax folder is empty, you need to remove the javax cache and let the Gradle download it again.
Upvotes: 0
Reputation: 3622
All your dependency is right, it's just an android studio bug!
I am having the same problem using Android Studio 4.2.2, I solved using the beta version of Android Studio
Upvotes: 1
Reputation: 66
I believe you are missing the plugins in the gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
Upvotes: 0