Andriod Application Crashing due to Camera in Some Specific Device

0
I'm facing a strange issue in my Mendix Native Mobile application related to the camera functionality, and I'm looking for some help or suggestions.Version : 10.24.13 native template : latest 14.1.21Scenario:I'm using the Native Mobile Resources module to access the device camera.When I open the camera and scan a QR code, everything works as expected initially.However, if I navigate back to the previous page and scan another QR code, repeating this process 2–3 times, the application unexpectedly crashes on some Android devices.On certain devices, the app crashes on the very first attempt, immediately after opening the camera and capturing/saving the image.Issue:The application suddenly closes and redirects to the Android home screen.There is no error message or visible exception in the Mendix application.The issue is not consistent across all devices. It happens on some Android devices but not others.Has anyone experienced a similar issue with camera handling in Mendix Native Mobile?I'm wondering whether this could be related to camera resource management, lifecycle handling, or some device-specific compatibility issue.Would anyone be interested in looking into this issue with me or sharing some suggestions on how to troubleshoot it?Any help or guidance would be greatly appreciated!Thanks in advance!
asked
2 answers
0

Hi Porassingh,

A crash that sends you back to the Android home screen with no Mendix error usually means the native Android side crashed, not the Mendix logic. Typical causes are running out of memory, a camera resource that isn’t released, or a device-specific problem. That also fits what you see: it happens only on some devices, and it gets worse when you reopen the camera repeatedly. Here are some things to try first:

  • Check the template version. Make sure your native template version matches your Studio Pro version (10.24.13 here). Also update the Native Mobile Resources module and the native dependencies to the latest compatible versions, then rebuild the native app.

  • Reduce the image size. If you use the Take picture action, lower the picture quality and the maximum width and height if those options exist in your version. Full-resolution photos can run low-end devices out of memory, which would explain the crash on the first attempt.

  • Don’t keep camera screens open. Make sure the camera or scanner page is closed properly before you navigate back, and avoid stacking several camera pages. Also delete or clear the captured image objects after you use them.

  • Test with “Don’t keep activities”. Turn this on in Android Developer options. It shows whether the crash is related to how Android handles the app’s lifecycle.

  • Compare devices. Note the Android version and low-memory status of the devices that crash, and compare them with the ones that work.


To find the real cause I need the device logs. You can capture them like this:

  1. On the phone, open Settings > About phone and tap Build number 7 times to enable Developer options.

  2. Go to Settings > Developer options and turn on USB debugging.

  3. Connect the phone to your computer with a USB cable. Accept the “Allow USB debugging?” prompt on the phone.

  4. Then check the log for the issue in Android Studio Logcat

Please share the part of the log around the crash (look for lines with “FATAL EXCEPTION”, “AndroidRuntime”, “OutOfMemory” or “signal 11”). Please also share the device model, the Android version, and whether this is a Make it Native, custom developer app or release build. With that I can narrow down the cause. Remove any sensitive data from the logs before posting.

Kindly mark this as the accepted answer if it helps.

answered
0

Hi Porassingh,

Since the camera works initially but the application crashes after navigating back and reopening it several times, I would investigate the native camera lifecycle and Android camera resource handling first.

The fact that the application closes completely without a Mendix error suggests a possible native Android crash rather than a normal nanoflow exception.

1. Check the camera and scanner lifecycle

Make sure the camera/scanner screen is not being kept active after navigation.

If you are using the Barcode Scanner widget, check whether it is correctly unmounted when navigating away.

Also verify that:

  • The scan result is processed only once.

  • Repeated scan callbacks do not trigger multiple navigation actions.

  • The camera screen is not reopened while the previous camera operation is still active.

  • Any custom camera implementation properly releases its camera resources when the screen loses focus.

If you are using the Native Mobile Resources Take picture action, also check that the previous action has completed before another camera operation starts.

2. Check Native Template and camera dependencies

Mendix has documented Android camera fixes in the 10.24 native client releases.

In particular, Make It Native 10.24.6 updated react-native-vision-camera to address an upstream Android camera initialization crash.

Since you are using Native Template 14.1.21, verify the camera library versions actually included in your custom native build and compare them with the relevant Mendix release notes.

If an applicable camera fix is missing, test a compatible updated Native Template and Native Mobile Resources version in a separate branch, then create a new native binary.

An OTA update alone cannot replace native camera libraries.

3. Capture the actual Android crash

This is the most important step.

Connect one of the affected Android devices through USB debugging and run:

adb logcat -c
adb logcat -v time > camera_crash.txt

Reproduce the crash by opening the camera, scanning, navigating back, and repeating the operation.

Stop logging with Ctrl+C.

Search the log for:

FATAL EXCEPTION
AndroidRuntime
SIGSEGV
CameraAccessException
CameraDevice
CameraService

Check the stack trace immediately before the application process terminates.

4. Isolate the camera operation

Test these scenarios separately:

  • Open and close the camera repeatedly without scanning.

  • Scan repeatedly without capturing or saving an image.

  • Capture an image without performing QR scanning.

  • Test on affected and unaffected Android devices.

This will help determine whether the crash is caused by camera initialization, barcode scanning, image processing, or navigation.

5. Test a compatible native rebuild

If the crash points to the native camera library, test with the latest compatible native dependencies and Native Template in a separate branch.

Make sure the installed Native Mobile Resources version is compatible with the Native Template and Studio Pro version.

Official references:

My recommendation: Start with Android Logcat on an affected device. If the stack trace points to camera initialization or the native camera library, update the affected dependency through a compatible native rebuild. If it points to repeated scan callbacks or navigation, correct the scanner lifecycle and prevent duplicate processing.

Hope this helps! If you find this answer helpful, please mark it as the accepted answer.

answered