The earth is round.
I tested your aia, it runs well with Android 9 but not with 10
Hi AnCaLu
Google have introduced new Security measures that limit an App to using it's own folder/directory the "Application Specific Directory". That is where you can store and collect your images. Everyone has this same problem!
Taifun's File Extension may help you to access or create the ASD:
https://puravidaapps.com/file.php
Hi ChrisWard.
I tried using that extension but it didn't work for me using that method. The QR extension does not recognize the path correctly.
The solution was to create a function that returns the path of the ASD file without the text "/storage/emulated/0". With that, the image could be saved in the application path and I could also show the image of the qr code.
I attach the aia where I modify everything.
QR.aia (60.7 KB)
When I compiled the project into an apk and tried it on my phone it wouldn't open. It just closed.
I tried on my tablet with android 6 and the same thing happened.
I tried an emulator and the same thing happened.
I do not know what it could be.
It works fine by testing it in MIT AI2 Companion.
Hi AnCaLu
I really don't understand what your App is for but I can see where the issue is. Note, Companion works because it is not subject to all the security rules.
qr.png is in the Assets (Media) folder of the App - that's OK, the App is stored there too, but it is a closed, secure area that only your App can access.
If the extension does not have access to the Assets folder, we must move the file to the ASD first. Taifun's file extension should work.
Not sure why you have a Procedure to remove '/storage/emulated/0/' as I think this is a legitimate part of the ASD path.........
I do not have the QR extension, so the attached code is untested, but this is the way it should work.
QR_mod.aia (61.3 KB)
Hi ChrisWard.
My application generates a qr code of the text that you write in the text field.
The "qr.png" image that is in the assets is just a logo that I place in the middle part of the generated qr image.
The asset image has nothing to do with the qr image generated by the extension, the qr image is stored in the ASD after the changes made previously.
The path of ASD already exists so I don't have a problem.
The problem I have now is when I compile it into an apk and then install it I open it and it closes.
Hi AnCaLu
Have you tried my Project as an APK?
.... add the error info Block to capture the cause of the App closing when opened. Are you using your own icon? If so, just remove that for now and see if the App still crashes.
https://www.professorcad.co.uk/appinventorsnippets#GetErrorInfo
I also tried compiling your project but the application still closes. I get the message that the application has stopped.
I also delete all the images in assets.
Also place the Get Error Info blocks but the information is never displayed. This must be because the app closes before it fully loads.
The aix qr is this:
What happens if the extension is removed?
If I remove the QR extension and disable the blocks of qr the application starts without problems.
¿Why will this happen?
It could be that the extension is out of date with the current App Inventor version. We do not use the extension until the button is pressed, so for it to cause a crash as the App is loading would seem to show an incompatibility or simply that App Inventor is expected to have something that it doesn't have (as an APK).
You could also try to capture the crash via logcat. I just tried that myself but in fact I can't get logcat to work on my Huawei Pro 30 - everything is in place, but logcat is "waiting for device".
The extension needs read and write permissions.
Also note that android 10 does not allow you to write in external storage.
Since the extension uses absolute path method so you should pass a complete path.
@ChrisWard I have something for you:
com.sunny.LogReader.aix (5.5 KB)
Actually it does almost nothing and same can be done using android terminal.
Do you have an example where the problem is solved?
Of course, it's possible to write in the external storage with Android 10:
/storage/emulated/0/...
and of course to the ASD.
However, if AI2 is targeting API 30 (Android 11) (probably late 2021), you can only write to the ASD.
Not if writing in the ASD.
No, I don't think so, because the APK crashes on all Android versions.
I am getting confused.
Which version of android introduce scoped storage?
See e.g. here:
If AI2 targets API 30 (Android 11) (→ end of 2021), this will no longer be possible.