小编Ape*_*nto的帖子

Android 数据存储 IOException 无法重命名为

我正在尝试在我的项目中实现 Jetpack Datastore。我正在使用该apha-01版本并且代码运行良好。然后我在Gradle文件中看到有新版本,所以我将其更新为alpha-03.

启动我的应用程序后,我遇到了另一个问题。我发现版本中没有找到 Proto 库,alpha-03所以我回滚到版本alpha-01。另外,我尝试过alpha-02。从那时起我遇到了以下错误:

 Process: com.montymobile.sands, PID: 19928
    java.io.IOException: /data/user/0/com.montymobile.sands/files/datastore/sns_preferences.preferences_pb.tmp could not be renamed to /data/user/0/com.montymobile.sands/files/datastore/sns_preferences.preferences_pb
        at androidx.datastore.SingleProcessDataStore.writeData$datastore_core_release(SingleProcessDataStore.kt:304)
        at androidx.datastore.SingleProcessDataStore.transformAndWrite(SingleProcessDataStore.kt:282)
        at androidx.datastore.SingleProcessDataStore$actor$1.invokeSuspend(SingleProcessDataStore.kt:165)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Run Code Online (Sandbox Code Playgroud)

我注意到发生这种情况是因为我依次保存了两个不同的密钥,每个密钥都在一个协程中。当我评论第二个操作时,它起作用了。谁能解释为什么会发生这种情况?以及如何保存我想要的尽可能多的值?

任何帮助,将不胜感激。

android datastore ioexception android-jetpack

5
推荐指数
1
解决办法
2364
查看次数

标签 统计

android ×1

android-jetpack ×1

datastore ×1

ioexception ×1