android / codelab-android-datastore

Apache License 2.0
227 stars 105 forks source link

Type mismatch. Required: DataStore<UserPreferencesRepository.UserPreferences> Found: DataStore<Preferences> #75

Open MmingY opened 5 months ago

MmingY commented 5 months ago

Problem: I followed every step mentined in the Codelab tutorial https://developer.android.com/codelabs/android-preferences-datastore?hl=zh-cn#5, but I encountered this problem"Type mismatch. Required: DataStore Found: DataStore".

TasksActivity viewModel = ViewModelProvider( this, TasksViewModelFactory( TasksRepository, UserPreferencesRepository(dataStore, this) ) ).get(TasksViewModel::class.java)

UserPreferencesRepository class UserPreferencesRepository constructor( private val userPreferencesStore: DataStore<UserPreferences>, context: Context )... data class UserPreferences(val showCompleted: Boolean)