Hilt Activity must be attached to an @AndroidEntryPoint Application
The solution to this problem was: Declare android:name = “.CoreApplication” in your AndroidManifest.xml file, in the <application …/>tag.
The solution to this problem was: Declare android:name = “.CoreApplication” in your AndroidManifest.xml file, in the <application …/>tag.
From version androidx.hilt:hilt-navigation-compose:1.0.0-alpha02 you can inject view model into Composable functions by: hiltViewModel<ViewModelType>() Example: @Composable fun LoginScreen(viewModel: LoginViewModel) {} LoginScreen( viewModel = hiltViewModel<LoginViewModel>() ) Android Developer Documentation compose and hilt UPDATE: import androidx.hilt.navigation.compose.hiltViewModel @Composable fun LoginScreen( viewModel: LoginViewModel = hiltViewModel() ){ val videos=vm.watchLater.observeAsState() val context= LocalContext.current }
From the documentation on how we Inject dependencies into Android classes, we can learn the following: Hilt can provide dependencies to other Android classes that have the @AndroidEntryPoint annotation. Hilt currently supports the following Android classes: Application (by using @HiltAndroidApp) ViewModel (by using @HiltViewModel) Activity Fragment View Service BroadcastReceiver So when you subclass any of … Read more
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 😉
Move the id “kotlin-kapt” to the bottom of plugins{} in build.gradle Module-level.
Go to https://dagger.dev/hilt/gradle-setup check Hilt currently version Update: For now, you can use the newest version. Kotlin:1.7.0 with Hilt:2.42