Geert
09/28/2021, 1:02 PMjava.lang.RuntimeException: Cannot create an instance of class app.medxpert.pgo.compose.privacy_agreement.PrivacyAgreementViewModel
The Preferences:
class Preferences @Inject constructor(
@ApplicationContext val context: Context
) {...}
My ViewModel:
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
@HiltViewModel
class PrivacyAgreementViewModel @Inject constructor(
private val sharedPrefs: Preferences,
) : ViewModel() {...}
How I call it:
@Composable
fun PrivacyAgreementView(
viewModel: PrivacyAgreementViewModel = hiltViewModel()
) {
What could be wrong?Caused by: java.lang.InstantiationException: java.lang.Class<app.medxpert.pgo.compose.privacy_agreement.PrivacyAgreementViewModel> has no zero argument constructor
but it is injected?FunkyMuse
09/28/2021, 9:03 PM