Am using `androidx.datastore:datastore-preferences...
# android
j
Am using
androidx.datastore:datastore-preferences:1.0.0-rc01
and seeing occasional crashes in play console (stack trace in thread) but can't reproduce locally....just in case anyone else has encountered this.
Copy code
java.lang.IllegalStateException: 
  at androidx.datastore.core.SingleProcessDataStore$file$2.invoke (SingleProcessDataStore.kt:168)
  at androidx.datastore.core.SingleProcessDataStore$file$2.invoke (SingleProcessDataStore.kt:163)
  at kotlin.SynchronizedLazyImpl.getValue (LazyJVM.kt:74)
  at androidx.datastore.core.SingleProcessDataStore.getFile (SingleProcessDataStore.kt:163)
  at androidx.datastore.core.SingleProcessDataStore.readData (SingleProcessDataStore.kt:380)
  at androidx.datastore.core.SingleProcessDataStore.readDataOrHandleCorruption (SingleProcessDataStore.kt:359)
  at androidx.datastore.core.SingleProcessDataStore.readAndInit (SingleProcessDataStore.kt:322)
  at androidx.datastore.core.SingleProcessDataStore.readAndInitOrPropagateFailure (SingleProcessDataStore.kt:311)
  at androidx.datastore.core.SingleProcessDataStore.handleRead (SingleProcessDataStore.kt:261)
  at androidx.datastore.core.SingleProcessDataStore.access$handleRead (SingleProcessDataStore.kt:76)
  at androidx.datastore.core.SingleProcessDataStore$actor$3.invokeSuspend (SingleProcessDataStore.kt:239)
  at androidx.datastore.core.SingleProcessDataStore$actor$3.invoke (SingleProcessDataStore.kt:8)
  at androidx.datastore.core.SingleProcessDataStore$actor$3.invoke (SingleProcessDataStore.kt:4)
  at androidx.datastore.core.SimpleActor$offer$2.invokeSuspend (SimpleActor.kt:122)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
  at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:571)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:750)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:678)
  at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:665)
hmm, looking at source code at that line I see
Copy code
check(!activeFiles.contains(it)) {
    "There are multiple DataStores active for the same file: $file. You should " +
            "either maintain your DataStore as a singleton or confirm that there is " +
            "no two DataStore's active on the same file (by confirming that the scope" +
            " is cancelled)."
}
that at least gives a clue as to what's happening....had thought it was only created once but obviously not!
f
Make sure your instance is singleton Edit: nvm you found it 😁
👍 3