question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to open camera in Marshmallow

See original GitHub issue

I have a problem when I run

IntentIntegrator.forSupportFragment(this).setOrientationLocked(true).setBeepEnabled(true).initiateScan();

I tried to run the same application in Lollipop, where it works flawlessly, and in Marshmallow, where I get an alert: “Sorry, the Android camera encountered a problem, etc. etc.”.

I’m running on the 3.0.3 version, although it happens on the 3.0.1 and 3.0.2 as well. It happens on both my Nexus 5 and the emulator.

That’s the stacktrace:

D/CameraPreview: resume()
D/CameraInstance: Opening camera
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb3fd4140
W/CameraBase: An error occurred while connecting to camera: 0
E/CameraInstance: Failed to open camera
E/CameraInstance: java.lang.RuntimeException: Fail to connect to camera service
E/CameraInstance:     at android.hardware.Camera.<init>(Camera.java:495)
E/CameraInstance:     at android.hardware.Camera.open(Camera.java:341)
E/CameraInstance:     at com.google.zxing.client.android.camera.open.OpenCameraInterface.open(OpenCameraInterface.java:83)
E/CameraInstance:     at com.journeyapps.barcodescanner.camera.CameraManager.open(CameraManager.java:121)
E/CameraInstance:     at com.journeyapps.barcodescanner.camera.CameraInstance$3.run(CameraInstance.java:158)
E/CameraInstance:     at android.os.Handler.handleCallback(Handler.java:739)
E/CameraInstance:     at android.os.Handler.dispatchMessage(Handler.java:95)
E/CameraInstance:     at android.os.Looper.loop(Looper.java:148)
E/CameraInstance:     at android.os.HandlerThread.run(HandlerThread.java:61)
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabebff00, error=EGL_SUCCESS
D/CameraInstance: Configuring camera
W/CameraManager: Failed to set rotation.
W/CameraManager: Camera rejected even safe-mode parameters! No configuration
E/CameraInstance: Failed to configure camera
E/CameraInstance: java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference
E/CameraInstance:     at com.journeyapps.barcodescanner.camera.CameraManager.setParameters(CameraManager.java:359)
E/CameraInstance:     at com.journeyapps.barcodescanner.camera.CameraManager.configure(CameraManager.java:139)
E/CameraInstance:     at com.journeyapps.barcodescanner.camera.CameraInstance$4.run(CameraInstance.java:171)
E/CameraInstance:     at android.os.Handler.handleCallback(Handler.java:739)
E/CameraInstance:     at android.os.Handler.dispatchMessage(Handler.java:95)
E/CameraInstance:     at android.os.Looper.loop(Looper.java:148)
E/CameraInstance:     at android.os.HandlerThread.run(HandlerThread.java:61)
D/CameraPreview: pause()
D/CameraInstance: Closing camera

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
wseemanncommented, May 23, 2016

These changes don’t appear to be fool proof. When using the latest version if you

1.) Grant permission to the camera and open a CaptureActivity 2.) Minimize the app, turn the camera permission off 3.) Return to the app

This will produce a crash. There should be a check when resuming the camera to ensure the permission has been granted.

2reactions
fahimkcommented, Oct 14, 2015

If you are compiling against sdk 23, you need to ask for camera permissions with the new permissions api before the scanner is launched

Read more comments on GitHub >

github_iconTop Results From Across the Web

android : camera doesn't open in marshmallow - Stack Overflow
I was getting a message on startup - It seems your device does not support camera (or it is locked). I traced the...
Read more >
how to fix failed to open camera camera may be in ... - YouTube
Are you looking for how to fix failed to open camera camera may be in use by another application samsung? In this video...
Read more >
Open Camera Discussion - failed to save photo - SourceForge
Hi, I'm using a Motorola Moto G 2nd with Marshmallow. my sd card is set to internal. when i take a picture with...
Read more >
Android – ERROR: failed to connect to camera service @ Android ...
Im trying to build a camera app (Im pretty new at this) When I run the application on real device its gives me...
Read more >
8 Solutions to Fix Camera Not Working on Android - Jihosoft
How to Fix Android Camera Failed Problem? ; First open your app drawer or select the 'Settings' from your home screen. Now find...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found