title: Fail to connect to camera service although declared permissions
body: <p>for some reason i am getting this error evan though i added the right permissions in the manifest, i am trying to use the camera and scan a barcode with google android mobile vision api</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.app.barcodescanner"&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE/&gt; &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-feature android:name="android.hardware.camera" /&gt;
      &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
  &lt;/uses-permission&gt;
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>java code:</p>
  
  <pre><code>package com.app.barcodescanner;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.SparseArray;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  import android.widget.TextView;
  
  import com.google.android.gms.vision.CameraSource;
  import com.google.android.gms.vision.Detector;
  import com.google.android.gms.vision.barcode.Barcode;
  import com.google.android.gms.vision.barcode.BarcodeDetector;
  
  import java.io.IOException;
  import java.util.ArrayList;
  
  public class MainActivity extends AppCompatActivity {
      SurfaceView cameraView;
      TextView barCodeInfo;
      CameraSource cameraSource;
      ArrayList&lt;String&gt; results = new ArrayList&lt;String&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          cameraView = (SurfaceView) findViewById(R.id.camera_view);
          barCodeInfo = (TextView) findViewById(R.id.code_info);
  
          final BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(this).setBarcodeFormats(Barcode.QR_CODE)
                  .build();
  
          cameraSource = new CameraSource.Builder(this, barcodeDetector).
                  setRequestedPreviewSize(640,480).build();
  
          cameraView.getHolder().addCallback(new SurfaceHolder.Callback() {
              @Override
              public void surfaceCreated(SurfaceHolder holder) {
                  try {
                      cameraSource.start(cameraView.getHolder());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
  
              @Override
              public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  
              }
  
              @Override
              public void surfaceDestroyed(SurfaceHolder holder) {
                  cameraSource.stop();
              }
          });
  
          barcodeDetector.setProcessor(new Detector.Processor&lt;Barcode&gt;() {
              @Override
              public void release() {
              }
  
              @Override
              public void receiveDetections(Detector.Detections&lt;Barcode&gt; detections) {
                  final SparseArray&lt;Barcode&gt; barcodes = detections.getDetectedItems();
  
                  if (barcodes.size() != 0) {
                      barCodeInfo.post(new Runnable() {    // Use the post method of the TextView
                          public void run() {
                              barCodeInfo.setText(    // Update the TextView
                                      barcodes.valueAt(0).displayValue
                              );
                          }
                      });
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p>here is the log of errors:</p>
  
  <pre><code>com.app.barcodescanner D/libEGL: eglInitialize EGLDisplay = 0x96f457c4
  com.app.barcodescanner I/OpenGLRenderer: Initialized EGL, version 1.4
  com.app.barcodescanner W/CameraBase: An error occurred while connecting to camera: 0 /com.app.barcodescanner D/AndroidRuntime: Shutting down VM
     /com.app.barcodescanner E/AndroidRuntime: FATAL EXCEPTION: main                                                                         Process: com.app.barcodescanner, PID: 19767                                                                           java.lang.RuntimeException: Fail to connect to camera service
                                                                                  at android.hardware.Camera.&lt;init&gt;(Camera.java:568)
                                                                                  at android.hardware.Camera.open(Camera.java:405)
                                                                                  at com.google.android.gms.vision.CameraSource.zzBZ(Unknown Source)
                                                                                  at com.google.android.gms.vision.CameraSource.start(Unknown Source)
                                                                                  at com.app.barcodescanner.MainActivity$1.surfaceCreated(MainActivity.java:41)
                                                                                  at android.view.SurfaceView.updateWindow(SurfaceView.java:712)
                                                                                  at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:209)
                                                                                  at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1014)
                                                                                  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2510)
                                                                                  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437)
                                                                                  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7397)
                                                                                  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
                                                                                  at android.view.Choreographer.doCallbacks(Choreographer.java:695)
                                                                                  at android.view.Choreographer.doFrame(Choreographer.java:631)
                                                                                  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                  at android.os.Looper.loop(Looper.java:158)
                                                                                  at android.app.ActivityThread.main(ActivityThread.java:7224)
                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
      05-15 13:48:49.549 19767-21028/com.app.barcodescanner I/Vision: Connection error: null
  </code></pre>