Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Proto DataStore: Unresolved reference dataStore

未关闭
#27 8 条评论 10 个 reaction 已指派 1 人 在 GitHub 查看

@mmoczkowski 已经在做这个了。

开始于 2022年9月9日。

评估

这个 Issue 还没有评估数据。

描述

Problem:

I followed every step mentined in the Codelab tutorial https://developer.android.com/codelabs/android-proto-datastore, but Android Studio can't resolve dataStore (unable to import androidx.datastore.dataStore)

How to reproduce the issue:
  1. Download the base project git clone https://github.com/googlecodelabs/android-datastore
  2. modify gradle file according to https://developer.android.com/codelabs/android-proto-datastore#4
  3. create folder /app/src/main/proto
  4. create file user_prefs.proto in /app/src/main/proto according to https://developer.android.com/codelabs/android-proto-datastore#5
  5. Build -> Clean Project
  6. Build -> Rebuild Project (proto files get successfully generated)
  7. Generate UserPreferencesSerializer in package data and insert Code mentioned in https://developer.android.com/codelabs/android-proto-datastore#5
  8. Add all missing imports in class UserPreferencesSerializer
  9. Modify TasksActivity according to https://developer.android.com/codelabs/android-proto-datastore#6

Now Android Studio marks by dataStore as Unresolved reference: dataStore and I'm also unable to import import androidx.datastore.dataStore

private val Context.userPreferencesStore: DataStore<UserPreferences> by dataStore(
    fileName = DATA_STORE_FILE_NAME,
    serializer = UserPreferencesSerializer
)

Please can someone tell me how I can resolve this issue? I followed every steps mentioned in the tutorial and compared the solution files with my local project, but it still doesn't work.

主要语言
Kotlin
星标
240
派生
113
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

android/codelab-android-datastore 的其他 Issue

查看 android/codelab-android-datastore 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。