File component - File.Exists does not work for files in the assets with the APK - bug

Both methods return false with the compiled app (APK, AAB):

Companion works. @ewpatton

Label 4 returns true / works with the APK (and Companion):

Definitely a bug... I will see if we can squeeze this into the 2.65 companion, but it might need to be addressed as part of 2.66.

1 Like

I think there is really no rush for this "harmless" bug (as the method seems to be used very rarely).

This is true. 1) It's only been a year since it was introduced and 2) hopefully one knows what assets they've put in their project in advance and don't need to test for their existence...

1 Like

I've filed an issue in the meantime.

1 Like

Yes, but often enough you don't delete the assets directory for Companion before testing a new app and therefore files from other apps are still there. These are then present during testing with Companion, but not in the compiled app. In order to more easily identify the reason for a possible crash/bug, it might be helpful if this method also works with the compiled app.

Yes... and I have occasionally wondered what the solution might be there, since it is a cause of a number of issues (also TinyDB for similar reasons). It is a fairly deep problem that would require some architectural changes to how the companion works that I'm not sure we'd be comfortable making at this point.


can it be that this is the same bug ?

this bring "true" in the APK even if the file do not exist.
the list seem to have 10 files no matter what i do.

Please prepare a test project as small as possible, which elicits this behavior and add it into this thread


No, checked with Compnion & APK on Android 13.

Uninstall the app first, i.e. before you test it again.

thanks, i do not know why the file.exist brought true, when the file didn't exist, but i used a work around.

thanks for the help.

It does not show "true" if the file doesn't exist.

Google does automatic backups of app specific directories, so it might be possible that it restored files from previously backed up installation of your app. In this case, you could manually go in using adb and delete the contents of the directory.

i tried to delete it, but it seems not to work:

it should have deleted the file after writing it in label5 but it doesn't,

i can see the file have the correct path, but it still do not delete it, and the number of files in this directory getting higher then 1.

did you set the file scope to App?
for the File.Delete method try a relative path, which start wth /Pictures...


as you can see in the second image, it give the correct path:

but still do not delete.

I can see that you are using an absolute path...
The suggestion was

Also what about


i will try the relative path.

the file.delete have only file name, not a scope, i added the scope as the absolute path

As I've already showon in post #12:

If the FileScope = App you must set the subfolder and the fileName:

The File component does not use an absolute or full path.

1 Like