RuntimeException: Fail to connect to camera service


#1

I’m getting a java.lang.RuntimeException when trying to run the camera for the first time. (I have coded everything up to Listing 19.12)
The source of the problem in my code points me to the onResume() method of CrimeCameraFragment.java, but as far as I can tell it is exactly the same as the listing (19.5).

Any thoughts?

My code:

@TargetApi(9) @Override public void onResume() { super.onResume(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { mCamera = Camera.open(0); // This is the line the error occurs } else { mCamera = Camera.open(); } }


#2

Solved the error!

In my manifest what I had written for the permission name was “android.permissionS.CAMERA” and errantly made permission plural.