Camera crashes, but only with published aab, using apk is OK!

I have an old camera application, that I had to update to target API36, so I rebuilt my app. I tested the apk and it is working fine. I have uploaded the aab file on Google Play Console, but when I install the App from Google Play, my App crashes and I get the following error:

My camera application is using ProCamera extension as well as a couple of other extensions: TaifunCamera, TaifunImage, TaifunTools, TaifunExif.

Any idea onhow to track this issue, as it is working fine when I use the AI Companion, or use the apk

for old apps, which have been published as apk files you can continue to upload apk files instead of aab

Taifun

Actually, my App was published in 2024 and I think it was already an aab file.

When I try to upload an apk file, itis refused:

How old was the prior version? If it was fairly old, it may predate when App Inventor started having to target a newer SDK version that would trigger permission notifications. Does the app have the Camera permission in the manifest and has it been granted in settings? If not, I could imagine the Camera API returns a null object since you don't have permission to use it. The built-in Camera component should know what to do but extensions may need to be updated if that's the case.

Thanks for your feedback.

Regarding the date and version, the first upload on Google play was in 2023:

Last working upload was in 2024.

There is no update of ProCamera (only one version released in 2021), see: ProCamera Extension

My App is requesting Camera Permission:

and it is in the manifest:

What is strange is that when I install the apk on my phone, it is working fine, while the app on Play Store (aab) is crashing.

My main issue is that I cannot really debug this as it is working locally with the companion and local apk.

I can share my project if it can help

Can you run logcat when you test your app from Google Play, this should provide some information as to what is crashing the app ?

You could also try removing extensions one at a time to see if this helps ( I see you use two camera extensions, I’d try removing one of the two for example )

Instead of saving a permission flag in TinyDB, use an extension that checks the actual permission status. You can go into the app settings after installation and simply check whether the camera permission has been granted.

Simply download the universal APK from the Google Play Console to your computer and test it on your test devices.

If it also doesn't work, decompile the APK and post the Manifest and/or upload it to Google Drive and post the link.

Thanks for your proposal to download the apk from Google Play Console.

I tried, and the downloaded apk (after un-installing the Google Play one) is working. When I started this apk I got the message to allow usage of camera, message I was not getting when installing from Google Play!

Then I un-installed it, and re-installed from Google Play, at that time I got the message to allow usage of camera, and it works! :grinning_face_with_smiling_eyes:

I assume that the flag “CameraP” I store in TinyDB was indicating that camera Permission was already granted, but actually it wasn’t.

I noticed that even when un-installing app some data in TinyDB are not always cleaned up (e.g. in some of my App the flag “FirstRun”), maybe that was the issue.

So two extra questions:

  • Is it correct to store in TinyDb the fact that the permission is granted?
  • How to make sure TinyDB is cleaned-up when un-installing an App

Thanks to you @Anke @TIMAI2 @ewpatton and all the App Inventor Community for the help and support you provide

Try this instead:

I just added support for helper blocks:

1 Like

As I mentioned here:

The TinyDB solution doesn't always work. When updating the app from APK to AAB, TinyDB data is preserved, but permissions are removed.

This still sounds like a bug in the extension though... In the Camera component, we check internally whether the permission is granted and if it is not then we prompt for it. The user should never have to manage permissions in this way. The user can also revoke the permission in the settings app, so it doesn't make sense to store permanent state between app runs.

1 Like

Pro Camera definitely causes an app crash if Camera permission is not granted before use.

Thanks for this extension: the right way to do it :grinning_face: (instead of TinyDB)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.