Android Question Camera2 crashing

Daica

Active Member
Licensed User
I have not touched any code related to the Camera2 code and now whenever I open the camera page, the app crash with the following error:

B4X:
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
Camera started
Camera Supported Hardware Level: LEVEL_3
camex2_getsupportedcapturesizes (java line: 654)
java.lang.IllegalArgumentException: Expected cameraId to be numeric, but it was:
    at android.hardware.camera2.CameraManager.getCameraCharacteristics(CameraManager.java:661)
    at anywheresoftware.b4a.objects.Camera2.GetScalerStreamConfiguration(Camera2.java:229)
    at anywheresoftware.b4a.objects.Camera2.GetSupportedCaptureSizes(Camera2.java:222)
    at b4a.ramp.camex2._getsupportedcapturesizes(camex2.java:654)
    at b4a.ramp.page_camera$ResumableSub_B4XPage_Appear.resume(page_camera.java:300)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1181)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8663)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

I didn't touch the code for the camera, so why is it happening all of a sudden?
Anyone got any ideas?
 
Solution
I finally found the cause.
The app was crashing and I was getting that error because I was trying to log the available preview sizes.

B4X:
For Each ps As CameraSize In cam.SupportedPreviewSizes
    Log("Width: " & ps.Width & " Height: " & ps.Height)
Next

Removing this code makes the app works again...

Daica

Active Member
Licensed User
I finally found the cause.
The app was crashing and I was getting that error because I was trying to log the available preview sizes.

B4X:
For Each ps As CameraSize In cam.SupportedPreviewSizes
    Log("Width: " & ps.Width & " Height: " & ps.Height)
Next

Removing this code makes the app works again...
 
Upvote 0
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…