After updating from androidx.camera:camera-view:1.0.0-alpha32
to androidx.camera:camera-view:1.1.0-beta01
I receive the next error when using CameraX
camerax_version = "1.0.2"
// CameraX
implementation "androidx.camera:camera-core:$camerax_version"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:1.1.0-beta01"
Error
java.lang.IllegalStateException: CameraX is not configured properly. The most likely cause is you did not include a default implementation in your build such as 'camera-camera2'.
at androidx.camera.core.CameraX.<init>(CameraX.java:109)
at androidx.camera.lifecycle.ProcessCameraProvider.getOrCreateCameraXInstance(ProcessCameraProvider.java:181)
at androidx.camera.lifecycle.ProcessCameraProvider.getInstance(ProcessCameraProvider.java:167)
It fails because you have different versions for the various androidx.camera.* libraries.
If you check this:
https://developer.android.com/jetpack/androidx/releases/camera
It has the following description:
From 1.1.0-beta01, all CameraX libraries will align the same version number. This will help developers track versions much easier and reduce the complexity of large version compatibility matrix.
So you need to use the same version for ALL camerax libraries.
The error is because you are using different api versions of same library , which couldn't find the new version of camera-camera2 api in the library .
val cameraVersion = "1.3.1"
implementation("androidx.camera:camera-lifecycle:$cameraVersion")
implementation("androidx.camera:camera-camera2:$cameraVersion")
implementation("androidx.camera:camera-view:$cameraVersion")
implementation("androidx.camera:camera-core:$cameraVersion")
This code works well without any errors
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With