Status Update
Comments
an...@gmail.com <an...@gmail.com> #2
Some additional observations:
- It seems it has only a chance to happen on the first start after fresh install
- According to Crashlytics the number of crashes = number of affected users. Which could mean it only happens once on the first run and never again.
- Also we do have backups disabled
Can there be a race? Given the code of the Okio ReadScope
seems the file doesn't exist when it's tried to be opened, but exists shortly after that
return try {
fileSystem.read(
file = path
) {
serializer.readFrom(this)
}
} catch (ex: FileNotFoundException) {
if (fileSystem.exists(path)) {
throw ex
}
serializer.defaultValue
}
ra...@google.com <ra...@google.com>
[Deleted User] <[Deleted User]> #3
Any update on the issue?
gh...@google.com <gh...@google.com> #4
We have the same issue. Did you try to update to 1.1.1?
an...@gmail.com <an...@gmail.com> #5
Update to 1.1.1 doesn't help.
tn...@google.com <tn...@google.com> #6
an...@gmail.com <an...@gmail.com> #7
exact same issue, we went from 1.0.0 to 1.1.1 and are encountering this!
an...@gmail.com <an...@gmail.com> #8
Did some testing: for 200 fresh app installs there is 10-15 crashes on startup on Android 14.
wo...@gmail.com <wo...@gmail.com> #9
We had the problem with 1.0.0, updating the lib to 1.1.0 didn't change anything.
wo...@gmail.com <wo...@gmail.com> #10
Downgrading from 1.1.1 to 1.0.0 has seemingly resolved the issue for us.
di...@gmail.com <di...@gmail.com> #11
Downgrading is not an option for us as we need multiplatform support.
wo...@gmail.com <wo...@gmail.com> #12
Right now, there doesn't seem to be a straightforward way to change the error handling here, without adding an abstraction above the DataStore itself.
[Deleted User] <[Deleted User]> #13
I'm not sure why the above error is happening. It seems to be expecting the file to be created first and then queried.
Is there a timing issue?
[Deleted User] <[Deleted User]> #14
an...@gmail.com <an...@gmail.com> #15
[Deleted User] <[Deleted User]> #16
Sorry for the delay of responding to this issue, as we've seen similar issues in the other bugs and followed up there. This is hard for us to debug as it seems to be a race condition and we cannot easily reproduce it and understand the root cause. Please help us by providing more details (device populations, API levels, or anything you discover as relevant to the bug distribution) from your observation of its occurrence! Also a sample app to reproduce would be great if possible.
In the meantime, I'll try to do some more investigation with the given information. Thanks for your patience.
an...@gmail.com <an...@gmail.com> #17
It does not seem to be limited to a specific API, I see logs on API 10 to 15.
These are the errors I see on Crashlytics on a Pixel 8 Pro (unfortunately I have not been able to reproduce locally):
Fatal Exception: java.io.FileNotFoundException: /data/user/0/com.myapp/files/datastore/tracked apps.preferences_pb: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:574)
at java.io.FileInputStream.<init>(FileInputStream.java:179)
at okio.Okio__JvmOkioKt.source(Okio__JvmOkio.kt:181)
at okio.Okio.source(Okio.java:1)
at okio.JvmSystemFileSystem.source(JvmSystemFileSystem.java:96)
at androidx.datastore.core.okio.OkioReadScope.readData$suspendImpl(OkioStorage.kt:227)
at androidx.datastore.core.okio.OkioReadScope.readData(OkioStorage.kt:1)
at androidx.datastore.core.StorageConnectionKt$readData$2.invokeSuspend(StorageConnection.kt:74)
at androidx.datastore.core.StorageConnectionKt$readData$2.invoke(StorageConnection.kt:20)
at androidx.datastore.core.StorageConnectionKt$readData$2.invoke(StorageConnection.kt:20)
at androidx.datastore.core.okio.OkioStorageConnection.readScope(OkioStorage.kt:113)
at androidx.datastore.core.StorageConnectionKt.readData(StorageConnection.kt:74)
at androidx.datastore.core.DataStoreImpl.readDataFromFileOrDefault(DataStoreImpl.kt:331)
at androidx.datastore.core.DataStoreImpl.access$readDataFromFileOrDefault(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invokeSuspend(DataStoreImpl.kt:378)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.SingleProcessCoordinator.tryLock(SingleProcessCoordinator.kt:50)
at androidx.datastore.core.DataStoreImpl.readDataOrHandleCorruption(DataStoreImpl.kt:377)
at androidx.datastore.core.DataStoreImpl.access$readDataOrHandleCorruption(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invokeSuspend(DataStoreImpl.kt:314)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.SingleProcessCoordinator.tryLock(SingleProcessCoordinator.kt:50)
at androidx.datastore.core.DataStoreImpl.readDataAndUpdateCache(DataStoreImpl.kt:312)
at androidx.datastore.core.DataStoreImpl.access$readDataAndUpdateCache(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readState$2.invokeSuspend(DataStoreImpl.kt:234)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
Caused by android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Linux.open(Linux.java)
at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8591)
at libcore.io.IoBridge.open(IoBridge.java:560)
at java.io.FileInputStream.<init>(FileInputStream.java:179)
at okio.Okio__JvmOkioKt.source(Okio__JvmOkio.kt:181)
at okio.Okio.source(Okio.java:1)
at okio.JvmSystemFileSystem.source(JvmSystemFileSystem.java:96)
at androidx.datastore.core.okio.OkioReadScope.readData$suspendImpl(OkioStorage.kt:227)
at androidx.datastore.core.okio.OkioReadScope.readData(OkioStorage.kt:1)
at androidx.datastore.core.StorageConnectionKt$readData$2.invokeSuspend(StorageConnection.kt:74)
at androidx.datastore.core.StorageConnectionKt$readData$2.invoke(StorageConnection.kt:20)
at androidx.datastore.core.StorageConnectionKt$readData$2.invoke(StorageConnection.kt:20)
at androidx.datastore.core.okio.OkioStorageConnection.readScope(OkioStorage.kt:113)
at androidx.datastore.core.StorageConnectionKt.readData(StorageConnection.kt:74)
at androidx.datastore.core.DataStoreImpl.readDataFromFileOrDefault(DataStoreImpl.kt:331)
at androidx.datastore.core.DataStoreImpl.access$readDataFromFileOrDefault(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invokeSuspend(DataStoreImpl.kt:378)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.DataStoreImpl$readDataOrHandleCorruption$2.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.SingleProcessCoordinator.tryLock(SingleProcessCoordinator.kt:50)
at androidx.datastore.core.DataStoreImpl.readDataOrHandleCorruption(DataStoreImpl.kt:377)
at androidx.datastore.core.DataStoreImpl.access$readDataOrHandleCorruption(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invokeSuspend(DataStoreImpl.kt:314)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.DataStoreImpl$readDataAndUpdateCache$4.invoke(DataStoreImpl.kt:16)
at androidx.datastore.core.SingleProcessCoordinator.tryLock(SingleProcessCoordinator.kt:50)
at androidx.datastore.core.DataStoreImpl.readDataAndUpdateCache(DataStoreImpl.kt:312)
at androidx.datastore.core.DataStoreImpl.access$readDataAndUpdateCache(DataStoreImpl.kt:53)
at androidx.datastore.core.DataStoreImpl$readState$2.invokeSuspend(DataStoreImpl.kt:234)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:115)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
gh...@google.com <gh...@google.com> #18
I've also been seeing this since updating from 1.0.0 (problem exists in both 1.1.0 and 1.1.1) and so I had to downgrade to 1.0.0 to avoid these crashes.
Has anyone tried:
UPDATE: no it doesn't help
an...@gmail.com <an...@gmail.com> #19
an...@gmail.com <an...@gmail.com> #20
br...@google.com <br...@google.com> #21
gh...@google.com <gh...@google.com> #22
Hi there - we were able to reproduce the issue on our end, a fix is in the works. I'll update here once we have it merged & ready for release.
gh...@google.com <gh...@google.com> #23
This issue should be fixed for the upcoming 1.1.3 release. Please let us know if the issue persists after the release.
ws...@gmail.com <ws...@gmail.com> #24
Project: platform/frameworks/support
Branch: androidx-main
Author: elifbilgin <
Link:
Resolve FileNotFoundException issue in OkioStorage at startup.
Expand for full commit details
Resolve FileNotFoundException issue in OkioStorage at startup.
This change introduces a second attempt at reading a file in OkioStorage `readData()`, in case the initial read attempt failed due to a race condition caused by in the file being created by a different process.
Bug: 337870543
Test: Tested locally via aosp/3496411.
Change-Id: I43b3fb565cc76344bc14c7dc3964ff76b2319358
Files:
- M
datastore/datastore-core-okio/src/commonMain/kotlin/androidx/datastore/core/okio/OkioStorage.kt
- A
datastore/datastore-core-okio/src/commonTest/kotlin/androidx/datastore/core/okio/OkioFakeFileSystem.kt
- M
datastore/datastore-core-okio/src/commonTest/kotlin/androidx/datastore/core/okio/OkioStorageTest.kt
- M
datastore/datastore-core/src/jvmAndroidMain/kotlin/androidx/datastore/core/FileStorage.kt
Hash: 3e2cc72ab89a0c011f99627a61eba045d7378cb5
Date: Thu Feb 13 23:25:56 2025
gh...@google.com <gh...@google.com> #25
still present in 1.1.2
only present on Android/JVM no problem on iOS
ws...@gmail.com <ws...@gmail.com> #26
Thanks for the update regarding the platform specific behavior, we are still working on pinpointing the issue
gh...@google.com <gh...@google.com> #27
ws...@gmail.com <ws...@gmail.com> #28
Apologies, this issue is resolved and the fix will be available in 1.1.3
gh...@google.com <gh...@google.com> #29
FYI the issue in
And to confirm, lint.do.not.reuse.uast.env
should no longer be needed at all in AGP 7.0+.
ku...@gmail.com <ku...@gmail.com> #30
Thanks #29 . I am noticing that when this happens, after the error log for
package fragment is not found for module:<lintWithKotlin> is a module
There is another error
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'descriptor' of org/jetbrains/kotlin/codegen/context/CodegenContext.intoPackagePart must not be null
at org.jetbrains.kotlin.codegen.context.CodegenContext.$$$reportNull$$$0(CodegenContext.java)
at org.jetbrains.kotlin.codegen.context.CodegenContext.intoPackagePart(CodegenContext.java)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1$1.invoke(LightClassDataProvider.kt:51)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1$1.invoke(LightClassDataProvider.kt:38)
at org.jetbrains.kotlin.asJava.builder.LightClassBuilderKt.buildLightClass(LightClassBuilder.kt:64)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1.invoke(LightClassDataProvider.kt:47)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject$computeLightClassData$1.invoke(LightClassDataProvider.kt:38)
at org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport.createDataHolderForClass(CliLightClassGenerationSupport.kt:64)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject.computeLightClassData(LightClassDataProvider.kt:45)
at org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForClassOrObject.compute(LightClassDataProvider.kt:61)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$1(CachedValueBase.java:235)
at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:113)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:72)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:236)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
at
Does the fix address both of these?
gh...@google.com <gh...@google.com> #31
package fragment is not found
and Argument for @NotNull parameter...
), the workaround in 4.2 is to put
systemProp.lint.do.not.reuse.uast.env=true
in your gradle.properties
file as described in
gh...@google.com <gh...@google.com> #32
Marking fixed in AGP 7.0.
That is, the lint.do.not.reuse.uast.env
workaround should no longer be needed in AGP 7.0+. And, you should no longer see the following warnings/errors while running Lint:
ERROR: package fragment is not found for module:<lintWithKotlin>...
ERROR: Could not generate LightClass for...
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'descriptor' of org/jetbrains/kotlin/codegen/context/CodegenContext.intoPackagePart must not be null
The issue is fixed due to the new "Lint partial analysis" mode (enabled by default) which creates a standalone UastEnvironment
instance for each module, thereby avoiding stale caches in the Kotlin compiler frontend.
Please comment on the bug if you see any similar errors in AGP 7.0+.
Description
AGP: 4.0.0 Kotlin: 1.3.72 JVM: from docker image: 8u252-jdk-slim
Failure happens in CI builds, which always are clean. Failures are random. Sometimes builds are a success, but more often it is not. Each time random classes failed. For example, in this case, failed this little data class:
I included full stacktrace as file