CameraX is not configured properly. The most likely cause is you did not include a default implementation in your build such as 'camera-camera2
Asked Answered
S

3

20

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)
Spangle answered 17/2, 2022 at 12:41 Comment(0)
E
29

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.

Emulsion answered 17/2, 2022 at 12:57 Comment(2)
Could not find androidx.camera:camera-view:1.0.2 if using camerax_version = "1.0.2" for all depsSpangle
so I guess I need to use 1.1.0-beta01 for all librariesSpangle
F
1

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

Frondescence answered 15/2, 2024 at 6:38 Comment(1)
Today it successfully works with camera 1.3.3, thanks a lot!!Intractable
G
0

If you are not using camera2 but still getting this error just like in my case then just use the stable version of 1.3.1 for rest of the camera apis you need, instead of the alpha-04 version as of now.

Gulden answered 15/2, 2024 at 7:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.