dlazaro66 / QRCodeReaderView

Modification of ZXING Barcode Scanner project for easy Android QR-Code detection and AR purposes
1.9k stars 491 forks source link

java.lang.RuntimeException: startPreview failed #45

Closed hafs-r closed 8 years ago

hafs-r commented 8 years ago

java.lang.RuntimeException: startPreview failed at android.hardware.Camera.startPreview(Native Method) at com.google.zxing.client.android.camera.open.CameraManager.startPreview(CameraManager.java:138)

lalitjadav007 commented 8 years ago

I have similar issue. Let me know if you find any solution.

lalitjadav007 commented 8 years ago

@hafsalrahman I found solution for this problem. First you have to download this library and import it as module. Then Edit in QRCodeReaderView class.

In That you find onSurfaceChanged Method. and

mPreviewWidth = mCameraManager.getPreviewSize().x; mPreviewHeight = mCameraManager.getPreviewSize().y;

        mCameraManager.stopPreview();
        mCameraManager.getCamera().setDisplayOrientation(90); // Portrait mode

        mCameraManager.startPreview();
        mCameraManager.getCamera().setPreviewCallback(this);

Just resplace

        mCameraManager.stopPreview();

with

        mCameraManager.startPreview();

I don't know whether it affect in any other code or not . But it worked for me.

dlazaro66 commented 8 years ago

@hafsalrahman are you running this on Android 5.0 or Android 6.0? If that's the case, please assert that you have camera permissions before start the customview

lalitjadav007 commented 8 years ago

Yes I am running on android 6.0. And i have also added camera permission.

On Mon, Jul 18, 2016 at 8:55 PM, David Lázaro notifications@github.com wrote:

@hafsalrahman https://github.com/hafsalrahman are you running this on Android 5.0 or Android 6.0? If that's the case, please assert that you have camera permissions before start the customview

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dlazaro66/QRCodeReaderView/issues/45#issuecomment-233362460, or mute the thread https://github.com/notifications/unsubscribe-auth/AOkUhBAZ3qfbDWmaZqaTjedoTLuopsCJks5qW5rpgaJpZM4IDnSO .

Regards, Lalit Jadav

dlazaro66 commented 8 years ago

Please checkout the sample project and see how we implemented the live camera permissions. This issue is related to that

hafs-r commented 8 years ago

it is working fine now

codemaster730 commented 7 years ago

@hafsalrahman how did you manage to get it working ?

segunmicheal27 commented 7 years ago

@lalitjadav007 and @hafsalrahman

While this method: mCameraManager.startPreview(); called twice

i think this is one of the stuff casing app to crash on some major phone