androidandroid-studioandroid-6.0.1-marshmallow

Why does my app crash when using android.hardware.Camera.Open()?


I am re-writing an app for most versions of Android. The app is set to call android.hardware.Camera.Open() on launch. When the app launches it gives the error Camera Error: Could not connect to camera

The permissions in AndroidManifest.xml are

<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.camera"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>`.

Why can't it connect to the camera?


Solution

  • Problem solved!

    The issue was simply a matter of capitalization. The line <uses-permission android:name="android.permission.camera"/> should actually read <uses-permission android:name="android.permission.CAMERA"/>. This happened because camera is a hardware feature, while CAMERA is a permission.