If you are running a Xamarin Android app and the screen is black or fails with the message "The device failed to give access to the camera":
- Check that the startScanning function is called.
- Check that your app has permission to use the camera. For this go to your project settings under "Android Application" and look through the "Required permissions", make sure that the Camera has a checkmark. Additionally, check the value for "Target Android version". If the target version is below Android 6.0/ (API level 23) there are no additional changes needed. Otherwise, you will have to make further adjustments as the Android permission system has changed with version 6.0:
- Check that you are asking for specific permissions during runtime (simply listing them in the manifest does not guarantee permissions anymore). You can find Xamarin specific information on this at https://blog.xamarin.com/requesting-runtime-permissions-in-android-marshmallow/
- Decrease the target Android SDK version to a value lower than 23, which will disable the new permission system. Alternatively you can also directly change the target SDK version by editing the AndroidManifest.xml and adjust targetSdkVersion there:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
- Check your app's permissions in the app manager of your Android device. It is possible that for some reason you declined to give it camera permission at an earlier point in time.
- Check that hardware acceleration is set to ON (if Android API level < 14)