dagger-hilt
Inject context with Hilt: this field leaks a context object
After I faced that warning I decided to profile memory to be guaranteed that the approach causes a memory leak, but what I found is quite interesting yeah, there is no leak it’s just a warning so don’t care about it anymore, happy coding 😉
Cannot create instance of viewmodel after using Hilt in Android
This happens to me when using Hilt , and that was because I forgot to add the @AndroidEntryPoint annotation on top of the fragment class. Both the fragment and the host activity should be annotated with this annotation.
Is ApplicationComponent deprecated?
ApplicationComponent being renamed to SingletonComponent, to allow usage of Hilt in non-Android Gradle modules link
Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
I had this issue after upgrading Kotlin to 1.5.20. Adding kapt.use.worker.api=false in gradle.properties worked for me the problem Checkout dagger issue Support for Kotlin 1.5.20
Dagger Hilt ‘Assisted’ and ‘ViewModelInject’ is deprecated. in Dagger Hilt View Model 1.0.0-alpha03
In alpha03, Use the new @HiltViewModel and the normal @Inject now as shown below. @HiltViewModel class MyViewModel @Inject constructor( private val repository: Repository, private val savedStateHandle: SavedStateHandle ) : ViewModel(), LifecycleObserver { // Some code }
The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found
I guess you re missing this dependency kapt “com.google.dagger:hilt-android-compiler:2.28-alpha” *First add the plugin apply plugin: ‘dagger.hilt.android.plugin’ *Secondly add the dependencies // Dagger Core implementation “com.google.dagger:dagger:2.37” kapt “com.google.dagger:dagger-compiler:2.37” // Dagger Android api ‘com.google.dagger:dagger-android:2.37’ api ‘com.google.dagger:dagger-android-support:2.37’ kapt ‘com.google.dagger:dagger-android-processor:2.37’ // Dagger – Hilt implementation “com.google.dagger:hilt-android:2.37” kapt “com.google.dagger:hilt-android-compiler:2.37” *Thirdly add the classpath classpath “com.google.dagger:hilt-android-gradle-plugin:2.28-alpha” PS : if you re … Read more
Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
I just hit this problem this morning. Do you have anything in your build.gradle that adds arguments to the annotationProcessOptions? For example: android { … defaultConfig { … javaCompileOptions { annotationProcessorOptions { arguments = [“room.schemaLocation”: “$projectDir/schemas”.toString()] } } } } If so, try changing from “arguments =” to “arguments +=”, as just using equals overwrites … Read more
DefaultActivityViewModelFactory not found
Removing the dependency on hilt-lifecycle-viewmodel causes the error to go away as it is no longer required in newer versions of hilt. Simply delete this line from your app level build.gradle file if you have it. implementation ‘androidx.hilt:hilt-lifecycle-viewmodel:x.x.x’
Plugin [id: ‘dagger.hilt.android.plugin’] was not found in any of the following sources
I am late for the answer. I was also facing the same problem in Android Studio Bumblebee because of the new Gradle syntax for adding dependencies at the project level. For adding Dagger Hilt in project-level you can use the following syntax: id ‘com.google.dagger.hilt.android’ version ‘2.41’ apply false At the time of writing this, the … Read more