Camera2 resolutions - "outputSizes must not be null" or "At least one stream configuration for IMPLEMENTATION_DEFINED must exist"

Viewed 268

I have a few devices reported by Crashlytics that they cannot return supported resolutions when using Camera2 API.

All reported devices runs Android 10

4 reported devices: Samsung Galaxy Note10+, Galaxy S20+, LG V60 ThinQ, sprd ums512_1h10_Natv (some noname device)

Errors like:

Fatal Exception: java.lang.AssertionError
At least one stream configuration for IMPLEMENTATION_DEFINED must exist

and

Fatal Exception: java.lang.NullPointerException
outputSizes must not be null

Method where it crashes

fun getRecordingResolutions(context: Context, cameraId: String): List<Size> {
    val characteristics = getCameraCharacteristics(context, cameraId)
    val map = characteristics.get(
        CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP
    )!!
    val outputSizes = map.getOutputSizes(MediaRecorder::class.java)
    return outputSizes.toList()
}

How is that possible?

Firebase Crashlytics screenshots:

enter image description here

enter image description here

0 Answers
Related