Reputation: 12293
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)
Upvotes: 22
Views: 15818
Reputation: 679
This is my solution to this problem:
In the file build.gradle
implementation "androidx.camera:camera-camera2:1.3.4"
Just put here, like this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.camera:camera-core:1.3.1"
// CameraX View para mostrar la vista previa de la cámara
implementation "androidx.camera:camera-view:1.3.1"
// CameraX Lifecycle para controlar la cámara con el ciclo de vida
implementation "androidx.camera:camera-lifecycle:1.3.1"
// CameraX Camera2, necesaria para que funcione CameraX
implementation "androidx.camera:camera-camera2:1.3.4"
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation('org.tensorflow:tensorflow-lite:2.4.0') { changing = true }
implementation('org.tensorflow:tensorflow-lite-gpu:2.6.0') { changing = true }
implementation('org.tensorflow:tensorflow-lite-support:0.1.0') { changing = true }
}
This library must fix your problem
Upvotes: 0
Reputation: 351
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.
Upvotes: 0
Reputation: 29
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
Upvotes: 2
Reputation: 7928
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.
Upvotes: 30