1
votes

In Nativescript using ML-kit text recognition for devices with sdk less than 23 when I pause the app and resume it brokes with an error:

System.err: Caused by: java.lang.RuntimeException: Camera initialization failed because the camera device was already opened(-16)

In sdk >= 23 it seems that it works fine, but the idea is to make that it works in all devices (my client device has android 5.5 so sdk < 23). I'm using the plugin on real time:

<FirebaseMLKitTextRecognition:MLKitTextRecognition
                id="ocrCam"
                class="ocrCam"
                width="100%"
                height="50%"
                processEveryNthFrame="3"
                preferFrontCamera="false"
                torchOn="{{ lightOn }}"
                pause="{{ pauseOCR }}"
                scanResult="onTextRecognitionResult" />

I read something about permissions like older versions no need them but new ones need them and it crashes when ask for them. But the issue where closed by "min sdk 23".

Are there any method to controll that crash or destroying the xml element on pause?

1
Are you setting pauseOCR to true when app is paused? - Manoj
Yes I tested with oauseOCR = true, collapse element and both. It really pauses view camera with a black block, but I have the same problem. (and in my >23 device it works perfectly without pausing and collapsing anything) - CVO

1 Answers

1
votes

Try releasing the camera on pause event of your application / activity.

// Where ocrCam should be reference to MLKitTextRecognition
ocrCam.camera.release();