自定义摄像机X内部活动/片段错误(需要汇编' compilesdkversion'设置为32或更高)
因此,我一直在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的build.gradle中,您需要将CompileSDK / Targetsdk设置为32。如果有设置,则可能还需要更新buildTools版本。
像这样,您可能需要更改此操作,因为这是针对KTS的:
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: