Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 6.0 RuntimeException: Fail to connect to camera service

Tags:

An error occurred with my app which ran in Nexus5 (Android6.0).

The error was

java.lang.RuntimeException: Fail to connect to camera service

I had added the permission to the AndroidManifest.xml.

But the app is OK with another phone(Android5.1), and genymotion AVD(Android 4.0).

The key code is below

 @Override public void onResume() {     super.onResume();     try {         mCamera = Camera.open();     }catch (Exception e){         Log.e(TAG,"open camera failed",e);     }  } 
like image 796
HelloSilence Avatar asked Oct 22 '15 08:10

HelloSilence


2 Answers

Write in your gradle.build targetSdkVersion 22. It is a temporary solution but work.

like image 131
fahad_sust Avatar answered Nov 27 '22 14:11

fahad_sust


open Settings -> Apps -> click you app -> Permissions -> open Camera permissions.
you can see: http://developer.android.com/training/permissions/requesting.html

like image 24
zzzmode Avatar answered Nov 27 '22 15:11

zzzmode