我对 kotlin 不熟悉。我有一个应用程序,它的构建工具版本为 29.0.3,以下代码运行良好。
init {
// Make sure that the view finder reference is valid
val viewFinder = viewFinderRef.get()
?: throw IllegalArgumentException("Invalid reference to view finder used")
// Initialize the display and rotation from texture view information
viewFinderRotation = getDisplaySurfaceRotation(viewFinder.display)
// Initialize public use-case with the given config
previewUseCase = Preview(config)
// Every time the view finder is updated, recompute layout
previewUseCase.setOnPreviewOutputUpdateListener { output ->
val vFinder = viewFinderRef.get() ?: return@setOnPreviewOutputUpdateListener
// To update the SurfaceTexture, we have to …Run Code Online (Sandbox Code Playgroud)