dagger-hilt Questions
1
Let's say I have this navigation structure:
That will look something like this with compose-navigation:
NavHost(navController = navController, startDestination = "login") {
composable(&...
Sweptback asked 20/1, 2023 at 13:28
4
I have a problem with Hilt and ViewModel. I'm getting RunTimeException:
MainViewModel> has no zero argument constructor
I spent hours to find what is wrong...
Here are sources from my code:
App...
Coretta asked 7/2, 2022 at 18:52
0
I have a case where I have multiple bottom sheet for one screen (more than 5) and each sheet content has their own viewModel provided by Hilt, something like this:
when(bottomSheetType){
BottomShe...
Philter asked 6/4, 2023 at 15:31
1
I checked this info https://developer.android.com/jetpack/compose/libraries#hilt-navigation how to inject ViewModel to a compose screen.
For now I implemeted like this for my test app:
NavHost(
na...
Kolinsky asked 24/3, 2022 at 13:10
3
Example:
I have a @Composable func WorkoutScreen(...) which injects a dedicated ViewModel (e.g. with hilt). It displays some different child composables like @Composable func ProgressView(...) and ...
Jerryjerrybuild asked 12/2, 2022 at 18:45
2
Solved
According to the official integration guide, you need to add
plugins {
id 'kotlin-kapt'
...
}
and
dependencies {
implementation "com.google.dagger:hilt-android:{hilt_version}"
kapt &...
Ruzich asked 3/5, 2022 at 20:11
4
Solved
I was trying to provide a common DataStore<Preferences> so that the same preference file could be used in multiple places but I got the helpful error message:
Cannot find symbol: DaggerMyApp...
Stockroom asked 11/12, 2020 at 13:47
1
I am having a lot of UnknownHostException thrown and the app is disconnected from the internet completely, this issue is happening in multiple apps I am working on the issue happens on Samsung and ...
Packard asked 19/9, 2022 at 14:8
4
Solved
After migrating the Hilt version from 2.33-beta to 2.35 my project has stopped building with the error given below:
A txt version:
error: cannot access DefaultActivityViewModelFactory
class file...
Egyptian asked 25/4, 2021 at 17:53
0
I'm using Android Studio for Android development with Kotlin. I have more than 40 Android modules in the project: some of them are Java module, some of theme are android module.
Kotlin Version = &q...
Expel asked 22/2, 2023 at 6:36
2
I am trying to find a solution in how to define Hilt in a certain fragment related scenario. I have the following setup:
Activity
Parent Fragment 1
Child Fragment 1
Child Fragment 2
...
Child Fr...
Memoried asked 29/4, 2021 at 11:24
1
I use dagger hilt in my project. I want to write UI test for some fragments. I need to mock the viewModel in the test class and associate it to the fragment under the test.. I read dagger hilt docu...
Falsecard asked 18/10, 2020 at 10:0
3
i wanna add a token to request headers in Interceptor . but now i dont now what should i do.
here is my datastore
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name =...
Antipater asked 18/5, 2021 at 4:25
2
Solved
Here i created application class dependency. now i want to access
@Module
@InstallIn(SingletonComponent::class)
class MyApplicationModule {
@Provides
fun providesMainApplicationInstance(applicati...
Ducks asked 20/3, 2022 at 12:50
4
I am trying to navigate lets say from onboarding to dashboard and beyond and pop the onboarding once user hits dashboard, but still with 'back action' I end up on onboarding again.
Here is the samp...
Landrum asked 28/7, 2021 at 13:4
3
Solved
I am using Hilt. After updating to 1.0.0-alpha03 I got warnings that @ViewModelInject is deprecated and I should use @HiltViewModel. But when I change it I got an error:
java.lang.RuntimeException:...
Antarctica asked 4/2, 2021 at 11:34
4
Solved
Starting a new project and I am experiencing the following error... I have tried other solutions but seem to be dated
Steps I have tried:
Double checked plugins (listed below)
Instance Run (not li...
Repellent asked 6/2, 2022 at 0:31
8
Solved
After upgrading dagger hilt(version: 2.31-alpha) ApplicationComponent.class can not find.
What is the alternative for a Component like RoomDatabase?
@Module
@InstallIn(ApplicationComponent::class)
...
Forsberg asked 1/2, 2021 at 6:41
5
Solved
I'm doing the same as shown in the documentation here.
I want to Inject the ViewModel into a Composable function (Screen), but I get this error:
Cannot create an instance of class
com.example.blot...
Twelve asked 20/4, 2021 at 13:34
3
Solved
I'm using Dagger-Hilt for dependency injection in my Android project, now I have this situation where I have a base abstract Fragment
BaseViewModel.kt
abstract class BaseViewModel constructor(
val...
Limner asked 24/6, 2021 at 14:27
4
Solved
I am using the new Hilt library for Dependency Injection version 2.28-alpha. I have followed the Hilt documentation and annotated the Application class with the @HiltAndroidApp annotation. But when...
Penrose asked 12/7, 2020 at 10:43
1
I have spent the hole week trying to add hilt dependency injection to my sample note application, android studio have been throwing on me error after an error.It got me mad, any way, in AppModule i...
Hygienist asked 3/10, 2022 at 21:27
3
Solved
I am first trying android ViewModel and Hilt DI
As i understand from below link, to initialize ViewModel with a value on run-time i should use ViewModelFactory
Use a ViewModelFactory
//ViewModel
cl...
Charr asked 30/6, 2020 at 5:19
2
I am trying to create MVVM app using Openweathermap API and hilt. I tried to inject my repository into my viewmodel primary constractor and creating a ViewModelFactory class, in order to pass the p...
Misdoing asked 13/2, 2022 at 21:27
2
In Android Hilt, you can apply the @Singleton annotation to a function like this:
@Module
@InstallIn(SingletonComponent::class)
object SomeModule {
@Singleton
@Provides
fun provideSomething():...
Stillness asked 29/11, 2022 at 8:25
© 2022 - 2025 — McMap. All rights reserved.