title: CameraDevice failing to create session [Camera2]
body: <p>I'm trying to use the <code>Camera2</code> API to stream camera data to a <code>SurfaceView</code>. I'm following this guide: <a href="http://pierrchen.blogspot.com.au/2015/01/android-camera2-api-explained.html" rel="noreferrer">Camera2 guide</a></p>
  
  <p>I cannot get past <code>step 5</code></p>
  
  <blockquote>
    <p>MainActivity.java::onCreate()</p>
  </blockquote>
  
  <pre><code>setContentView(R.layout.activity_main);
  
  surfaceView = (SurfaceView)findViewById(R.id.surface);
  manager = (CameraManager)getSystemService(Context.CAMERA_SERVICE);
  </code></pre>
  
  <blockquote>
    <p>MainActivity.java::onClick()</p>
  </blockquote>
  
  <pre><code>for (String id : manager.getCameraIdList()) {
      CameraCharacteristics characteristics = manager.getCameraCharacteristics(id);
  
      Integer direction = characteristics.get(CameraCharacteristics.LENS_FACING);
  
      if (direction != null &amp;&amp; direction == CameraCharacteristics.LENS_FACING_BACK) {
          if (checkCallingOrSelfPermission("android.permission.CAMERA") == PackageManager.PERMISSION_GRANTED)
              manager.openCamera(id, new StateCallback(), null);
  
          break;
      }
  }
  </code></pre>
  
  <blockquote>
    <p>MainActivity.java.StateCallback::onOpened(CameraDevice camera)</p>
  </blockquote>
  
  <pre><code>List&lt;Surface&gt; surfaces = new LinkedList&lt;&gt;();
  surfaces.add(surfaceView.getHolder().getSurface());
  
  CaptureRequest.Builder builder = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
  builder.addTarget(surfaces.get(0));
  
  camera.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() {
      @Override
      public void onConfigured(CameraCaptureSession session) {
          Log.i(TAG, "Configured");
      }
  
      @Override
      public void onConfigureFailed(CameraCaptureSession session) {
          Log.e(TAG, "Configured failed"); // Ends up in this function :(
      }
      }, null);
  </code></pre>
  
  <p>The program ends up in the <code>onConfigureFailed()</code> function. I don't know what could be the error, and I don't know how to check what is.</p>
  
  <p>My guess would be that I'm missing something in the <code>CaptureRequest</code>, but I have no idea what.</p>
  
  <p>I'm running on a <a href="https://en.wikipedia.org/wiki/Samsung_Galaxy_S4" rel="noreferrer">Samsung Galaxy S4</a>.</p>