title: How to configure the capture size in Camera 2 API
body: <p>I'm making an android camera application. My doubt is how do I pass the supported resolutions as parameters to the camera.</p>
  
  <p>So, first I'm getting all the supported resolution sizes:</p>
  
  <pre><code>Size[] sizes = configurationMap.getOutputSizes(ImageFormat.YUV_420_888);
  Log.d("test","size:"+sizes.length);
  
  for(Size size : sizes){
      Log.d("test", "width: " + size.getWidth() + " height" + size.getHeight());
  }
  </code></pre>
  
  <p>Then I'm configuring the input with one of these sizes.</p>
  
  <pre><code>InputConfiguration inputConfiguration = new InputConfiguration(1920, 1080, ImageFormat.YUV_420_888);
  </code></pre>
  
  <p>The I'm passing this input to a capture session</p>
  
  <pre><code>cameraDevice.createReprocessableCaptureSession(inputConfiguration, Arrays.asList(previewSurface), new CameraCaptureSession.StateCallback() {
      @Override
      public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
          try {
              cameraCaptureSession.setRepeatingRequest(mCaptureRequestBuilder.build(), null, handler);
          } catch (CameraAccessException e) {
              e.printStackTrace();
          }
      }
  
      @Override
      public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
          Toast.makeText(getApplicationContext(),"Camera Preview Failed!!",Toast.LENGTH_SHORT).show();
      }
  }, null);
  </code></pre>
  
  <p>And, I'm also getting an </p>
  
  <pre><code>java.lang.IllegalArgumentException: input size 1920x1080 is not valid
  </code></pre>
  
  <p>error, though this size is supported on my phone camera (from the debug result of <code>getOutputSizes()</code>).</p>
  
  <p>So, my question is on my approach and where I'm wrong.</p>