android / android/camera-samples

CameraUnavailableException

Open
#465 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
5.5k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

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...

Contributor guide

Open the contributing guide

Research direction

Start with the reported CameraFragment.setUpCamera call at line 253, the full CameraUnavailableException trace, and the listed CameraX 1.1.0-alpha01 dependencies. Reproduce the CAMERA_IN_USE failure on the Samsung Galaxy J7 Max running Android 8, then document a confirmed cause and fix or a minimal sample demonstrating the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.