PathFromUri function works on AI Companion, But not when building .apk

Hello, I'm trying to build an app where I can browse a file (.csv) from the phone, and then display the contents in a label.
The app works perfectly fine when using the AI Companion, but when I build the .apk and install the app on my phone, I get the following error:

Here are my blocks that i used to test the apk (not the full app that works on the companion, but the block that's causing the issue):

Any idea why this "PathFromUri" function works on companion but not apk? and how do i fix it? This is using the FileTools Extension by Sunny.
This was tested on android 11. it works for android 9.

Thank you.

Which version of extension are you using?
Make sure it is the latest one.

This is the version I'm using:
I downloaded it a few days ago just in case there was an updated release. I'm pretty sure this is the latest one, I could be wrong..

Can you send apk link?

Where does the CSV file come from?
If the file comes from the external storage (e.g. /storage/emulated/0Download/file.csv) it only works if the user grants manually → MANAGE_EXTERNAL_FILES permission:

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_FILES"/>

This permission is declared in the Manifest if you use the FileTools extension from @vknow360.
The TaifunFile extension from @Taifun does not declare it.


  • grant MANAGE_EXTERNAL_FILES in the app settings and try again and / or
  • try to move the file from the external storage to the ASD an open / read it from there.

@vknow360 I cannot upload the apk directly here, so here's a link:

@Anke the CSV file comes from the external storage, it could be from /storage/emulated/0Download/file.csv or from any other external folder on the phone.
The app allows the user to browse a file (CSV and txt), and then display the contents in a label.
the whole app works on the companion, but not when building the actual apk..

I haven't gotten to the part of reading the file yet, it does work on the companion (I did have to copy the file to the ASD and then read it from there, for android 11, and did read it the traditional way for android <11. I can include the blocks but that's not the problem I'm facing in the apk (yet?) ).

Are those permissions that you mentioned also responsible for the PathFromUri function? because I can't get to the "Read File" part without getting the file's path.. I've researched how to edit the manifest, I found your guide here . Will try it and post the results soon..

Thank you for your help and time!

@Floof_h this works for media files.

Yes, but also for all files (non-media files).
For media files you only need READ permission to access those files.
But for non-media files (like .txt or .csv), that are not created by the app you need MANAGE_EXTERNAL_FILES to access those files if they are stored in the external storage (outside of the ASD).

But I am getting same error after selecting pdf and txt files.
Image files are working.

For image (media) files you only need READ permission.

How was this file saved there? Who / which app created this file?
The app can only access it if the csv (non-media) file is created by the app itself.

this not really is a solution, because usually apps, which use that permission are rejected by Google, see here, there are a few exceptions...

we still want to be able to access files, which have been provided by other apps in the shared directories... it looks like it is not possible anymore in App Inventor now starting with the new SDK30 release? However theoretically it is possible to still access these files.... see here @ewpatton, do you plan to add this back into App Inventor?

When should you request the All files access permission?

You should only access the all files access permission when your app cannot effectively make use of the more privacy friendly best practices, such as using the Storage Access Framework or the Media Store API


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


Of course, and I didn't say that this is a solution.
I just wanted to show one way how it would work. It is clear that this is not an option for an app that is to be published in the Play Store.

Yes, it remains to be seen whether this will be implemented in AI2 ...

@Anke The file comes from the user. Basically, the file is a route to use for navigation.. the user creates his desired route (outside the app, using a website) and then downloads the route file to his phone. where the file ends up being, I don't know. I don't know the file's name either.. the app should be able to work with that.. (as any other normal app would). the user should be able to browse his phone's file (open the file manager from the app) and then select the file. then display the contents in a label, for starters..

@Taifun I did end up succeeding in reading files from the external storage, both on android 11, and on android 9, using your help and @TIMAI2 help from the previous thread I posted. However, this only worked on the companion... when I compiled the .apk, it stopped working, mainly because of what I mentioned in this thread (the "PathFromUri" function isn't working for android 11) but this function worked for android 9, though the "ReadFrom" function to read the file, was unsuccessful (on the apk).

Here's the situation again, for now:

  1. On the companion:
    I managed to read files from external storage, regardless of where/how the file was created. both on android 11 and on android 9 (so all SDK?). the whole app works as desired.
  2. Compiled .apk
    On android 11, the "PathFromUri" function isn't working, so I didn't even get to try to read the file because I can't even get it's path. so i need to fix this, before moving on to test the "ReadFrom" function to read the file..
    On android 9, the "PathFromUri" function works. however, I haven't succeeded yet to read the file because I believe the response from the "FileCopied" isn't successful. so there's a problem with the "CopyFileAsync" on my android 9..

Here are the blocks for the whole situation:

Thank you all for your help!

This Android 11 thing is quite confusing. :roll_eyes:

Can you show the blocks?
Maybe something is wrong with path.

I posted all of the blocks in the previous post. It should deal with both android 11 and 9 (SDK above 29 and below..)
But here it is again, with a few notes:

The path is correct on android 9. it's the CopyFileAsync that's not working as intended. Do you mean the path that's used as the source for the CopyFileAsync? this is the path that I get: image
On android 11, I cannot even get the path, using the "PathFromUri" function. it's returning nothing..

I asked for copy file blocks.Found it, sorry.
Also you should always rely on successful (Boolean) param.

Here they are:

I cannot control the param that's returned as a response I believe.. it's returned from the "FileCopied" function.. I tried it as a boolean first, but it returned an error, so i displayed it as a text and saw the value it returned (which is copy successful if the file was copied successfully).

I think I have found the problem.Lemme open my laptop.

No worries, take your time. thank you a lot for your help!

I have to say again though, that the app works when using the AI2 companion, but not when building the .apk

Thank you again..