我不断收到此错误。当我尝试使用 CameraX 库打开相机时。相同的代码在少于 pie 的其他设备上运行。但不在饼图上运行(相机未显示)
这是我的代码:而且我还在我的项目中使用生活数据会导致任何问题吗?
val previewConfig = PreviewConfig.Builder()
.setLensFacing(CameraX.LensFacing.BACK)
.build()
val preview = Preview(previewConfig)
preview.setOnPreviewOutputUpdateListener { previewOutput ->
_textureView.surfaceTexture = previewOutput.surfaceTexture
}
val imageAnalysisConfig = ImageAnalysisConfig.Builder()
.build()
val imageAnalysis = ImageAnalysis(imageAnalysisConfig)
val qrCodeAnalyzer = QRCodeAnalyzer { qrCodes ->
qrCodes.forEach {
Log.d("MainActivity", "QR Code detected: `${it.rawValue}.")`
val intent = intent.putExtra("RESULT",it.rawValue)
setResult(Activity.RESULT_OK,intent)
finish()
}
}
imageAnalysis.analyzer = qrCodeAnalyzer
// We need to bind preview and imageAnalysis use cases
CameraX.bindToLifecycle(this as LifecycleOwner , preview, imageAnalysis)
日志:查看我收到的日志
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context
E/GLConsumer: [SurfaceTexture-0-3196-1] updateAndRelease: GLConsumer is not attached to an OpenGL ES context