Parag2385 / Picker

Picker - A CameraX based WhatsApp Style Image-Video Picker
103 stars 11 forks source link

Camera preview not started #1

Closed ivan200 closed 3 years ago

ivan200 commented 4 years ago

Device: meizu 15 logcat:

2020-08-03 22:46:42.337 24580-24580/com.appexecutors.pickersample E/Picker: Use case binding failed
    java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0.  May be attempting to bind too many use cases. Existing surfaces: [] New configs: [androidx.camera.core.impl.VideoCaptureConfig@4fba973, androidx.camera.core.impl.ImageCaptureConfig@fa82aad, androidx.camera.core.impl.PreviewConfig@f9076d7]
        at androidx.camera.lifecycle.LifecycleCameraRepository.bindToLifecycleCamera(LifecycleCameraRepository.java:266)
        at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:424)
        at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:275)
        at com.appexecutors.picker.Picker.bindCameraUseCases(Picker.kt:276)
        at com.appexecutors.picker.Picker.access$bindCameraUseCases(Picker.kt:74)
        at com.appexecutors.picker.Picker$startCamera$1.run(Picker.kt:134)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6394)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1000)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:890)
        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

if i replace cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture, videoCapture) to cameraProvider.bindToLifecycle(this, cameraSelector, preview) then preview is started, but i cant take picture

Parag2385 commented 4 years ago

Hello @ivan200

First of all, thank you for using this library.

Secondly, I didn't understand the context behind your replacement of the cameraProvider.bindToLifeCycle method. Could you please explain it as to why are you trying to replace this one?

And the reason you're not able to take a picture or even a video, because without the use cases such as imageCapture and videoCapture you're not providing any config to the preview. Without this configuration, it's just a preview, nothing else.

I'll be more of help only if you provide me with me context for this move of yours.

Thank you.

ivan200 commented 4 years ago

Secondly, I didn't understand the context behind your replacement of the cameraProvider.bindToLifeCycle method. Could you please explain it as to why are you trying to replace this one?

i just tried to make your lib working and not crash camera. But simple replacement is not working, and i was lazy so i just write here and hope you can fix your lib.

Parag2385 commented 4 years ago

Okay, it is because of the CameraX APIs, the device you're using might not be supported, you can try providing imageCaputure only

replace cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture, videoCapture) with cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture)

This is just an assumption, as I'm not able to reproduce this issue. Also, you can try it on some other device and emulator. Let me know how that goes.

akshay-nayak commented 3 years ago

Hi can u use only camera without gallery?

Parag2385 commented 3 years ago

Hello, @akshay-nayak , no you cannot use it without the gallery, as this is supposed to replicate the WhatsApp Image picker behavior. But maybe I can add support for it. I'll look into it over the weekend, and will let you know.