Я пытаюсь использовать CameraX API для получения фотографии, но после обновления до новой версии API 1.0.0-alpha06 он начал падать при методе
CameraX.bindToLifecycle(...)
.
Журнал ошибок:
Process: com.aximetria.aximetria.debug, PID: 2629
java.lang.BootstrapMethodError: Exception from call site #2 bootstrap method
at androidx.camera.core.Preview.updateListener(Preview.java:368)
at androidx.camera.core.Preview.updateOutput(Preview.java:586)
at androidx.camera.core.Preview.updateConfigAndOutput(Preview.java:363)
at androidx.camera.core.Preview.onSuggestedResolutionUpdated(Preview.java:524)
at androidx.camera.core.UseCase.updateSuggestedResolution(UseCase.java:408)
at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:684)
at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:195)
at com.aximetria.aximetria.ui.main.profile.avatar.TakeAvatarPhotoFragment.initCamera(TakeAvatarPhotoFragment.kt:169)
at com.aximetria.aximetria.ui.main.profile.avatar.TakeAvatarPhotoFragment.initCamera$default(TakeAvatarPhotoFragment.kt:117)
at com.aximetria.aximetria.ui.main.profile.avatar.TakeAvatarPhotoFragment$onViewCreated$1.onPermissionsChecked(TakeAvatarPhotoFragment.kt:55)
...
Мой код:
private fun initCamera(reverseFacing: Boolean = false) {
...
val previewConfig = PreviewConfig.Builder()
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
.setLensFacing(lensFacing)
.build()
val preview = Preview(previewConfig)
preview.setOnPreviewOutputUpdateListener { previewOutput ->
val parent = binding.preview.parent as ViewGroup
parent.removeView(binding.preview)
parent.addView(binding.preview, 0)
binding.preview.surfaceTexture = previewOutput.surfaceTexture
}
val captureConfig = ImageCaptureConfig.Builder()
.setFlashMode(flashMode)
.setLensFacing(lensFacing)
.build()
val capture = ImageCapture(captureConfig)
binding.takeAPhoto.setOnClickListener {
...
val imageFile = createTempFile(System.currentTimeMillis().toString(), ".jpg")
capture.takePicture(imageFile, this, object : ImageCapture.OnImageSavedListener {
override fun onImageSaved(file: File) {
...
}
override fun onError(imageCaptureError: ImageCapture.ImageCaptureError, message: String, cause: Throwable?) {
...
}
})
}
CameraX.bindToLifecycle(this, capture, preview)
}
Кто-нибудь знает, что вызвало этот сбой? Я не вижу никакой связанной информации в документации (которая к настоящему времени устарела для CameraX)