Essentials: [Bug] [FilePicker] [Android] Exception is thrown when picking some files

Created on 28 Oct 2020  路  7Comments  路  Source: xamarin/Essentials

Description

Java.IO.FileNotFoundException: File is virtual is thrown when pciking some files from Google drive. Not sure what are those virtual files exactly, but probably some file entities on Google Drive which have some dynamic content (just a pure guess).

Steps to Reproduce

  1. Have such "virtual file" on your google drive
  2. Try to pick it
  3. Call OpenReadAsync on FileResult

Expected Behavior

Either throw Net exception (and not a Java one) or pick the file (if it's possible to pick those virtual files at all).

Actual Behavior

Throws Java exception

Basic Information

  • Version with issue: 1.6.0-pre2
  • Last known good version:
  • IDE: VS 2019
  • Platform Target Frameworks:

    • Android: 11.0

  • Affected Devices: Tested on Google Pixel 3a
bug

All 7 comments

How do you create a "virtual file"? And do you have a stack trace for us?

It feels like any document created on google drive and shared with you might be a virtual file

  1. Have 2 Google accounts, one of which is used on the testing device.
  2. Sign in into Google Drive with the second account, create Google document, and share it with viewer permission with your main account
  3. Pick that file on the device

Java.IO.FileNotFoundException: File is virtual: acc=3;doc=encoded=oX0eiSgeztRLkXJOtaCmP93xC/+3eZbLp1WycFZK1PDDSRi/98GX2Gj/ at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <42748fcc36b74733af2d9940a8f3cc8e>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <42748fcc36b74733af2d9940a8f3cc8e>:0 at Android.Content.ContentResolver.OpenInputStream (Android.Net.Uri uri) [0x00031] in <227a96d68a0440cea172be41b1306654>:0 at Xamarin.Essentials.FileBase.PlatformOpenReadAsync () [0x0001e] in D:\a\1\s\Xamarin.Essentials\FileSystem\FileSystem.android.cs:119 at Xamarin.Essentials.FileBase.OpenReadAsync () [0x00000] in D:\a\1\s\Xamarin.Essentials\FileSystem\FileSystem.shared.cs:105 at QQQ.uploadFile (Xamarin.Essentials.FileResult fileData) [0x001ee] in qqqqq.cs:554 --- End of managed Java.IO.FileNotFoundException stack trace --- java.io.FileNotFoundException: File is virtual: acc=3;doc=encoded=oX0eiSgeztRLkXJOtaCmP93xC/+3eZbLp1WycFZK1PDDSRi/98GX2Gj/ at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:151) at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:781) at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1983) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1798) at android.content.ContentResolver.openInputStream(ContentResolver.java:1475) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

We have the same problem. Is there a WA?

https://stackoverflow.com/questions/46422736/how-to-open-inputstream-for-a-virtual-file-on-the-cloud

this methods can detect that file is virtual, but cant open stream for file..
Method for get virtual file return exception: Java.IO.FileNotFoundException: File is virtual.
@IngweLand, how did you solve the problem? Did you manage to open the virtual file?

for filter virtual files when create intent need add string:
intent.AddCategory(Intent.CategoryOpenable);

this string disabled files, which can't loaded from other apps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkIvanDev picture MarkIvanDev  路  4Comments

tsjdev-apps picture tsjdev-apps  路  4Comments

nicolgit picture nicolgit  路  4Comments

craylward picture craylward  路  4Comments

gabry90 picture gabry90  路  3Comments