I want use Jetpack DataStore in my app and according to setup instruction in: https://developer.android.com/topic/libraries/architecture/datastore I have added the following to my build.gradle.kts(:app)
dependencies {
implementation("androidx.datastore:datastore-preferences:1.0.0")
}
then to store key-value pairs I have added this line at the top level of my kotlin file:
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
but on this step after import android.content.Context to my kotlin file, I have Unresolved reference: dataStore error and Property "dataStore" is never used warning
You should have the following two dependencies in your app:
build.gradle.ktsThen at least following imports in your Kotlin file: