Bishwajeet Biswas
Bishwajeet Biswas

Reputation: 69

QRCodeReaderView library crashing my android application

After updating to QRCodeReaderView latest version my app crash is still not stopped, different issue getting. Fatal Exception: java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.(Camera.java:565) at android.hardware.Camera.open(Camera.java:372) at com.google.zxing.client.android.camera.open.OpenCameraInterface.open(OpenCameraInterface.java:76) at com.google.zxing.client.android.camera.CameraManager.openDriver(CameraManager.java:96) at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:183) at android.view.SurfaceView.updateWindow(SurfaceView.java:579) at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5786) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5296) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Upvotes: 0

Views: 424

Answers (2)

oyenigun
oyenigun

Reputation: 637

Check your permission on Manifest file. If you launched the application on android 6.0+, you should use permission request like below;

 // Here, thisActivity is the current activity
    if (ContextCompat.checkSelfPermission(thisActivity,
                     Manifest.permission.CAMERA)
            != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                 Manifest.permission.CAMERA)) {

            // Show an explanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(thisActivity,
                    new String[]{ Manifest.permission.CAMERA},
                    MY_PERMISSIONS_REQUEST_CAMERA);

            // MY_PERMISSIONS_REQUEST_CAMERA is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    }

Upvotes: 0

dlazaro66
dlazaro66

Reputation: 41

I'm the author of the library and I just released a new 2.0 with several improvements, try to update to the latest version and see if the issue is solved.

Please check it out here: https://github.com/dlazaro66/QRCodeReaderView and if it doesn't work, open an issue there.

Upvotes: 0

Related Questions