I'm building an Android app that uses Dagger-Hilt. Altough Dagger-Hilt is in my build.gradle file as you can see below,
build.gradle (project file)
:
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
}
}
...
build.gradle (app file)
:
...
dependencies {
...
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-compiler:2.38.1"
...
}
I get an "unresolved reference" for hiltViewModel()
in the MainActivity.kt
file,
@Composable
fun Home(
viewModel: MainViewModel = hiltViewModel()
) {
...
}
I do not understand why ?
androidx.hilt:hilt-navigation-compose
, more info: developer.android.com/jetpack/compose/libraries#hilt-navigation. – Mullen