title: java.lang.RuntimeException: setParameters failed in Camera Api
body: <p>I am developing Camera overly app in that i am using camera api for preview and overlay effects.I am getting force close error in some mobiles and it is not happening other mobiles.</p>
  
  <p>My code:</p>
  
  <pre><code>parameters = camera.getParameters(); 
  List&lt;Size&gt; sizes = parameters.getSupportedPreviewSizes(); 
  Size optimalSize = getOptimalPreviewSize(sizes, w, h); 
  parameters.setPreviewSize(optimalSize.width, optimalSize.height);
  parameters.setColorEffect(Camera.Parameters.EFFECT_SOLARIZE);
  setCameraDisplayOrientation(MainActivity.this,0, camera); 
  camera.getParameters(); 
  camera.setParameters(parameters);
  </code></pre>
  
  <p>These are the call stacks I am getting</p>
  
  <pre><code>    java.lang.RuntimeException: setParameters failed
      at android.hardware.Camera.native_setParameters(Native Method)
      at android.hardware.Camera.setParameters(Camera.java:1046)
      at com.androidpixels.watercamera.MainActivity.surfaceChanged(MainActivity.java:1241)
      at android.view.SurfaceView.updateWindow(SurfaceView.java:575)
      at android.view.SurfaceView.updateWindow(SurfaceView.java:407)
      at android.view.SurfaceView.dispatchDraw(SurfaceView.java:352)
      at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
      at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
      at android.view.View.draw(View.java:6936)
      at android.widget.FrameLayout.draw(FrameLayout.java:357)
      at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1917)
      at android.view.ViewRoot.draw(ViewRoot.java:1530)
      at android.view.ViewRoot.performTraversals(ViewRoot.java:1266)
      at android.view.ViewRoot.handleMessage(ViewRoot.java:1868)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3693)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Please help me. what could be the reason?</p>