camera-samples icon indicating copy to clipboard operation
camera-samples copied to clipboard

CameraUnavailableException

Open d-rahul opened this issue 3 years ago • 1 comments

I am facing the below issue on a specific Android phone (Samsung Galaxy J7 Max, Android OS 8):

Caused by java.util.concurrent.ExecutionException androidx.camera.core.InitializationException: androidx.camera.core.CameraUnavailableException: androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat: CAMERA_IN_USE (4): connectHelper:1769: Camera "0" is already open

Below is complete log trace which I am getting in crashlytics: Caused by java.util.concurrent.ExecutionException: androidx.camera.core.InitializationException: androidx.camera.core.CameraUnavailableException: androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat: CAMERA_IN_USE (4): connectHelper:1769: Camera "0" is already open at androidx.concurrent.futures.AbstractResolvableFuture.getDoneValue(AbstractResolvableFuture.java:518) at androidx.concurrent.futures.AbstractResolvableFuture.get(AbstractResolvableFuture.java:475) at androidx.concurrent.futures.CallbackToFutureAdapter$SafeFuture.get(CallbackToFutureAdapter.java:199) at androidx.camera.core.impl.utils.futures.FutureChain.get(FutureChain.java:155) at androidx.camera.core.impl.utils.futures.ChainingListenableFuture.get(ChainingListenableFuture.java:105) at com.myapp.camerax.fragments.CameraFragment.setUpCamera$lambda-3(CameraFragment.java:253) at com.myapp.camerax.fragments.CameraFragment.lambda$EMsPyTVNt0SkjjvLhSi7bXqFvsM(CameraFragment.java:3) at com.myapp.camerax.fragments.-$$Lambda$CameraFragment$EMsPyTVNt0SkjjvLhSi7bXqFvsM.run(lambda:3) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7025) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Gradle dependencies, I am using: // CameraX core library implementation "androidx.camera:camera-core:1.1.0-alpha01" // CameraX Camera2 extensions implementation "androidx.camera:camera-camera2:1.1.0-alpha01" // CameraX Lifecycle library implementation "androidx.camera:camera-lifecycle:1.1.0-alpha01" // CameraX View class implementation 'androidx.camera:camera-view:1.0.0-alpha21' // Image compressor implementation 'id.zelory:compressor:3.0.0'

Any fix will be appreciated...

d-rahul avatar Feb 02 '22 09:02 d-rahul

Hello, Could you give a little more information on this issue? Are you getting this bug in CameraXBasic?

Also, could you try to upgrade your version of CameraX to 1.1.0-beta01 for all artifacts? It's possible this issue may have been addressed already.

temcguir avatar Feb 03 '22 19:02 temcguir