Media not existent on Build .apk

Hi everyone!

I need your help with the process of building my app. I have some media in my app e.g. PNG, mp3, CSV when I build the apk only the mp3 is existent. The CSVs and PNGs are missing. What am I doing wrong?

Thanks for your help!

welcome
why do you think, they are missing? How did you find out? Any screenshot of some relevant blocks?
Did you upload these files in the media section of the designer?
Any screenshot of the media section?

Taifun

1 Like

Thank you for your answer!
Media
This is the media included in the designer. When i test the app all pictures are shown in the app in the right spot (PNG as Icons in ListView) and the CSV is loaded correctly (Items of ListView). However when I buld the app as apk and download it over the provided QRCode, all the Pictures are missing and the CSV can not be found by the app.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


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

1 Like

I managed to get the pictures to show. I had to remove a "/". Now only the CSV is missing.
Here ist the code loading the CSV:


And this is the one writing to it:

File1 scope is set to private.
Hope this helps

To read a file from the assets you have to set the file scope to Asset
The assets are read only, therefore you have to store the file for example in the ASD... file scope for that is App...

See also Some basics on Android storage system

See also the documentation Storage

Taifun

1 Like

I changed the File1 scope to App but it will still not find it on startup. I am able to write it, thus create it and afterwards read it but on fist start of the app it can not be found. but this is the same when i change the scope back to Private since both should be R/W

So the question is why it is not able to find the CSV on first launch after installation. Where are the files of the Media designer stored? ... Is it because the Media is stored under Assets?

You would need to copy the csv file from assets to the private directory before you can read the csv file from the private directory for the first time

1 Like

So I would need to check if the file exists in Private and if thats not the case change file scope to asset, load he CSV change back to Private and save it?

something like that. probably just these blocks

image

1 Like

Thank you both for the help. I now have a much better understanding of the scopes. The app is now working as intended. Here are the changes I implemented:
A little check for the CSV in the Private file scope:
1
The reset of the file scope to private:
2

I have no idea what this topic is actually about
"Media not existent on Build .apk"

What do the assets and their (non)existence in the APK have to do with it? :upside_down_face: :woman_shrugging:

My guess is, @LMLandkraut did not test using the companion app?

Taifun

I did and everything worked fine without the modifications. When I build the app as .apk it didn't work anymore, so I asked for help. Maybe the files are handled differently when testing over the companion app.

I had some pictures and a CSV which was used in my app. While testing on the companion app the pictures showed and the cab was able to be read and written. However when I exported the APK and installed it on my phone the pictures didn't show and the CSV was not found by the app.

As already explained, media and non-media files in the assets can be read at any time. However, the assets can only be read. In order to get write access, these must be copied to a directory with write access when the app is started (or when it is needed). In principle, the following directories come into consideration for this purpose:

  1. the ASD
  2. the privateDir or
  3. one of the Shared folders.

All directories should be writable and readable without storage permissions (READ / WRITE), at least on Android 11+. Below Android 11, storage permissions are only required for Shared folders. As of Android 4.4 (API 19), storage permissions are no longer required for the ASD. (The privateDir is in the internal storage and cannot be found on the device without a rooted device.)

The problems you describe can only occur if option 3 (Shared folder) was selected. Then a file can only be saved/overwritten if it was created by the same app. So if you have previously tested with Companion, the APK will no longer allow you to create/overwrite the same file again because Companion is a different app. Therefore, access to this file is then denied with the APK.

So the title of your topic makes no sense and is misleading. Adjust it please.

Also see here:

Thank you for your effort but as I wrote the file scope was not set to shared but private. The other users already helped me out to find and fix the problem in a very professional and quick way. Thanks to them I now understand what I was doing wrong and need no further explanation. The topic can be closed.

But I would like to understand it too and I should definitely be able to understand it since I'm pretty familiar with the Android file system.

Of course, other people should also be able to understand it. But I doubt they can understand it until now.

Um es kurz zu machen: Poste doch mal die ursprünglich aia Version, bei der das Problem auftrat. Dann kann ich sofort erkennen, wo das Problem lag.