You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please double check your setup, that the Activity or Fragment are annotated with @AndroidEntryPoint. That your runtime and annotation processor dependencies are in the module and that the Hilt Gradle plugin is applied.
Hilt can't provide View Model by factory using viewModel() function in composable function. Every time I got:
Caused by: java.lang.NoSuchMethodException: com.example.myapplication.HomeViewModel.<init>
My ViewModel class
@HiltViewModel class HomeViewModel @Inject constructor(val testClass: TestClass) : ViewModel() { fun test() { testClass.test() } }
Composable:
`@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
@composable
fun HomeScreen(
modifier: Modifier = Modifier,
viewModel: HomeViewModel = viewModel()
) {
Button(onClick = { /TODO/ }) {
}
}`
The text was updated successfully, but these errors were encountered: