-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Error from logcat is:
FATAL EXCEPTION: main Process: com.name.app, PID: 22818 java.lang.IllegalArgumentException: Failed to determine if primary:Pictures/Wallpaper/38qs4xw3x5k71_result.jpg is child of primary:Pictures/Wallpaper: java.io.FileNotFoundException: Missing file for primary:Pictures/Wallpaper at /storage/emulated/0/Pictures/Wallpaper at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142) at android.content.ContentProviderProxy.query(ContentProviderNative.java:481) at android.content.ContentResolver.query(ContentResolver.java:1226) at android.content.ContentResolver.query(ContentResolver.java:1158) at android.content.ContentResolver.query(ContentResolver.java:1114) at com.lazygeniouz.dfc.resolver.ResolverCompat.getCursor(ResolverCompat.kt:133) at com.lazygeniouz.dfc.file.internals.SingleDocumentFileCompat$Companion.make$dfc_release(SingleDocumentFileCompat.kt:99) at com.lazygeniouz.dfc.file.DocumentFileCompat$Companion.fromSingleUri(DocumentFileCompat.kt:222) at com.name.app.feature.ViewModel$updateImages$1.invokeSuspend(AppViewModel.kt:56) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8762) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b0e134b, Dispatchers.Main.immediate]
The code that yields the error is:
if (viewModel.coverUri != null) { val coverFile = DocumentFileCompat.fromSingleUri(context, viewModel.coverUri.toUri()) if (coverFile == null || !coverFile.exists()) { repository.updateImage(null)) } }
Other sections of my code also yield the same error and what's responsible seems to be fromSingleUri and methods that it uses. I couldn't figure out what was wrong with it specifically. Maybe you'll have some insight into this.
The same code works with DocumentFile (the original). I can confirm that the content URI is not the problem because I have other libraries as well as official ones that work with it perfectly.