an error occurred by CameraX.bindToLifecycle()

前端 未结 5 2082
执念已碎
执念已碎 2021-01-02 06:54

java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0. May be attempting to bind too many use cases.

5条回答
  •  没有蜡笔的小新
    2021-01-02 07:30

    A workaround is to bind Preview with VideoCapture, and Preview with ImageCapture separately. Binding Preview, ImageCapture and VideoCapture appears to be an issue on a few devices currently. When switching between the two be careful to unbindAll first.

    This may be because the VideoCapture UseCase is not officially supported yet, as of 1.0.0-Beta10.

    fun startVideoCapture() {
            ...
                    cameraProvider.unbindAll()
                    cameraProvider.bindToLifecycle(
                                    lifecycleOwner,
                                    cameraSelected,
                                    previewUseCase,
                                    videoCaptureUseCase
                                )
                    }
    fun startImageCapture() {
            ...
                    cameraProvider.unbindAll()
                    cameraProvider.bindToLifecycle(
                                    lifecycleOwner,
                                    cameraSelected,
                                    previewUseCase,
                                    imageCaptureUseCase
                                )
                    }
    

提交回复
热议问题