title: Android camera2 API error in call to createCaptureSession
body: <p>Trying to get the camera2 API working, but am getting some exception when trying to create the capture session. The Surface list contains a single non-null Surface. The API docs state that the last param can be left as null to use the current thread's looper. I also have tried creating a separate thread to do this but it did not fix it. This is all happening on a Galaxy Note 5 running Lollipop</p>
  
  <pre><code>public void onOpened(CameraDevice camdev){
  if(camdev!=null) {
      try {
          CaptureRequest.Builder captureRequest = camdev21.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
          captureRequest.addTarget(imageSurfaceList.get(0));
          camdev.createCaptureSession(imageSurfaceList, new CaptureSessionStateHandler(), null);
      } catch (CameraAccessException e) {
          e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>Any clues? Could it be that Samsung's Camera2 implementation just sucks and I should use the depreciated Camera class (I already got that to work)?</p>
  
  <blockquote>
    <p>11-20 00:24:15.620 3097-3651/? E/CameraDeviceClient: beginConfigure:
    Not implemented yet.</p>
    
    <p>11-20 00:24:15.620 3097-4969/? E/CameraDeviceClient: createStream:
    bufferProducer must not be null</p>
    
    <p>11-20 00:24:15.620 25601-25601/? D/AndroidRuntime: Shutting down VM</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime: FATAL EXCEPTION:
    main</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime: Process:
    com.made4engineering.socialselfieapp, PID: 25601</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:
    java.lang.IllegalArgumentException: Bad argument passed to camera
    service</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.utils.CameraBinderDecorator.throwOnError(CameraBinderDecorator.java:114)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.utils.CameraBinderDecorator$CameraBinderDecoratorListener.onAfterInvocation(CameraBinderDecorator.java:73)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.utils.Decorator.invoke(Decorator.java:81)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    java.lang.reflect.Proxy.invoke(Proxy.java:397)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    $Proxy2.createStream(Unknown Source)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.impl.CameraDeviceImpl.configureOutputsChecked(CameraDeviceImpl.java:378)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:437)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    com.made4engineering.socialselfieapp.CameraHandler$CameraStateHandler.onOpened(CameraHandler.java:471)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:118)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.os.Handler.handleCallback(Handler.java:739)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.os.Handler.dispatchMessage(Handler.java:95)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.os.Looper.loop(Looper.java:145)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    android.app.ActivityThread.main(ActivityThread.java:6897)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Native Method)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    java.lang.reflect.Method.invoke(Method.java:372)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)</p>
    
    <p>11-20 00:24:15.620 25601-25601/? E/AndroidRuntime:     at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)</p>
  </blockquote>