Issue: Fail to read file from asset in APK. OK from Companion

I am facing an issue reading a csv file from asset.
I have a csv file in asset, and when I read it, it works when using the companion, but fails: File1.GotText is not executed when apk is run.

This bug happens only if location sensor is used in the project (otherwise it is working fine)

Looks like, sensor permission request for sensor is asked first, while giving permission, read is blocked, when file access permission is asked and granted, read request has been lost and is not performed.


test.csv (15 Bytes)
Test.aia (2.2 KB)

As you say, It's likely the case that the App has not finished initializing before it tries to read the file. Try this:

Snap5

....adjust the time interval until it works reliably.

Thanks for your help and feedback. I made some test, and this seems to be working, but it is difficult to define the proper timing, and it looks more like a workaround then a real solution. I found some exchan ge on this topic such s: Potential Permissions Problems but it is not very clear for me:

  • If the app inventor application itself needs to ask for permission, or if it is directly handled by app inventor implementation?
  • How can we make sure the permission has been granted if it is handled by App inventor?
  • How to check multiple permission at the initialization?

What is the best way to handle these permissions?

Thanks a lot to the App Inventor community

One more aspect not clear for is if we need to permission to read file in the asset: //filename ? According to: http://appinventor.mit.edu/blogs/evan/2020/08/08/file-path-updates-android-10 this is not required, but looks like Application is asking automatically for it?

reading from the assets does not need permission, howewer the file component unfortunately asks for it... as workaround you can use this extension

this most probably also fixes your other issue...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

No, this a (new) bug. → @ewpatton
The File component has never (before) required READ permission when reading from the assets.

Regarding the location permission see here:

Try this one: → Test2.aia (20.0 KB)
as @Taifun suggested (until the bug is fixed).

Thanks a lot Anke and Taifun. EFile is working fine for me :slight_smile:

2 posts were split to a new topic: How is it possible to read asset file with iOS?