Home Ask Login Register

Developers Planet

Your answer is one click away!

Aggressor February 2016

An error occurred while connecting to camera: 0 --- Fail to connect to camera service

I have a phone specific problem when I open a camera on this one particular Nexus 5. Its the An error occurred while connecting to camera: 0 --- Fail to connect to camera service error. On at least a dozen other phones everything works just fine. Other apps that use the camera on the Nexus 5 are not crashing (indicating its not all apps that can't access the camera, just mine).

There are a number of other questions on this and I have tried all of them. They all talk about missing permissions, and making sure the camera is destroyed after use.

To be clear my manifest requests and uses the camera properly:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera2" />

And I am releasing the camera when destroying:

public void releaseCamera()
    if (_camera != null)
        _camera = null;


Can you think of any reason what-so-ever that I am getting this. I have a suspicion that theres some sort of bug because I am using camera and not camera2 but that is a wild guess. Reading the updates for API 6.0 there is a section on camera that says:

In This release, the model for accessing shared resources in the camera service has been changed from the previous “first come, first serve” access model to an access model where high-priority processes are favored.

Again without re-writing the entire app to use camera2 (not an option) I can't say for certain what's going on.

Here is my code where I open the camera (and what works on e


Aggressor February 2016

So it looks like the culprit has something to do with the 6.0.1 update this phone went through.

While this didn't happen on other phones, it did on the failing Nexus 5.

What happened was the 6.0.1 update allows users to set individual permissions for an app. So somehow the persmission for the camera were toggled off. Turning this back on fixed the issue.

To get there you go to Settings -> Apps -> [App Name] -> Permissions

enter image description here

Post Status

Asked in February 2016
Viewed 3,926 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life