自定义摄像机X内部活动/片段错误(需要汇编' compilesdkversion'设置为32或更高)

发布于 2025-02-05 19:34:45 字数 1299 浏览 4 评论 0原文

因此,我一直在尝试使用Camerax在活动/片段中创建自定义相机。迄今为止,该家族的最新版本(Androidx.Camera ...)为1.2.0-Alpha02。因此,我从1.1.0-beta01更新它们(顺便说一句,在bindtolifecycle函数上抛出了一个AbstractMethodError`cameraproviderfuture.addlistener

({{ //用来将摄像机的生命周期结合到生命周期所有者 Val Cameraprovider:ProcessCameraprovider = CamerapRoviderFuture.get()

        // Preview
        val preview = Preview.Builder()
            .build()
            .also {
                it.setSurfaceProvider(viewFinderBack.surfaceProvider)
            }

        // Select back camera as a default
        val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

        try {
            // Unbind use cases before rebinding
            cameraProvider.unbindAll()

            // Bind use cases to camera
            // AbstractMethodError is thrown by bindToLifecycle
            cameraProvider.bindToLifecycle(
                this, cameraSelector, preview)

        } catch(exc: Exception) {
            Log.e(TAG, "Use case binding failed", exc)
        }

    }, ContextCompat.getMainExecutor(con!!))`) 

如果有人对此有解决方案,我很乐意使用旧版本的摄像头。

无论如何,在更新版本后,我运行同步,并且由于以下原因,它最终无法scynrchonize ...

依赖性'androidx.camera:camera-lifecycle:1.2.0-alpha02'需要 “ CompileSdkversion”将设置为32或更高。汇编目标 模块':app'是'android-31'

So I've been trying to create a custom camera inside an activity/fragment using CameraX. As at now, the latest version of that family of cameras (androidx.camera...) is 1.2.0-alpha02. So I update them from 1.1.0-beta01 (which was not working by the way threw an AbstractMethodError at the bindToLifeCycle function

`cameraProviderFuture.addListener({
// Used to bind the lifecycle of cameras to the lifecycle owner
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()

        // Preview
        val preview = Preview.Builder()
            .build()
            .also {
                it.setSurfaceProvider(viewFinderBack.surfaceProvider)
            }

        // Select back camera as a default
        val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

        try {
            // Unbind use cases before rebinding
            cameraProvider.unbindAll()

            // Bind use cases to camera
            // AbstractMethodError is thrown by bindToLifecycle
            cameraProvider.bindToLifecycle(
                this, cameraSelector, preview)

        } catch(exc: Exception) {
            Log.e(TAG, "Use case binding failed", exc)
        }

    }, ContextCompat.getMainExecutor(con!!))`) 

if anyone has a solution to this, I'd be happy to use the old version of cameras.

Anyway, after updating the versions, I run the sync and it ends up failing to scynrchonize for the following reason...

Dependency 'androidx.camera:camera-lifecycle:1.2.0-alpha02' requires
'compileSdkVersion' to be set to 32 or higher. Compilation target for
module ':app' is 'android-31'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩饰不了的爱 2025-02-12 19:34:45

在您的build.gradle中,您需要将CompileSDK / Targetsdk设置为32。如果有设置,则可能还需要更新buildTools版本。

像这样,您可能需要更改此操作,因为这是针对KTS的:

android {
    compileSdk = 32
    buildToolsVersion = "32.0.0"
    compileSdkVersion = 32
}

Within your build.gradle you need to set compileSDK / targetSDK to 32. You may also need to update your buildTools version too if you have that set.

Something like this, you may need to change this as this is for KTS:

android {
    compileSdk = 32
    buildToolsVersion = "32.0.0"
    compileSdkVersion = 32
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文