Type mismatch. Required: DataStore<UserPreferencesRepository.UserPreferences> Found: DataStore<Preferences>
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start with TasksActivity and UserPreferencesRepository, then compare their DataStore generic types with step 5 of the linked Android Preferences DataStore codelab. Reproduce the compiler error and confirm the repository constructor and call site use the same preference type so the project builds.
Written by the indexing model from the issue text.
Description
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<UserPreferencesRepository.UserPreferences> 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)
- Dominant language
- Kotlin
- Stars
- 240
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from android/codelab-android-datastore
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
android/codelab-android-datastore#83 · 1 comment · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in android/codelab-android-datastore
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Anthonyy232/Paperize#614 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Issue: Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
OpenAPITools/openapi-generator#24978 ·
-
helsemelding-json-schema json-schema-core
Difficulty 2/5 1-3 hours Newbie friendliness 68/100