You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Process: com.androidluckyguys, PID: 6480
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:2034)
at com.androidluckyguys.ARCamera.surfaceChanged(ARCamera.java:215)
at android.view.SurfaceView.updateWindow(SurfaceView.java:634)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:161)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2265)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1286)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6536)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:619)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
I solved the problem when the preview camera doesn't show up and being force closed.
I tried with high end LG devices and debug the ARCamera code to verify some values related to dimension supported.
I start with finding the preview value for width and height from surfaceChanged() :
I got the supplied value was 1440 for width and 2072 for height. And this is the problem, the dimension supplied was too big and
not supported by the device itself. So I compared with the received value in supportPreviewSizes and I got :
SupportedPreviewSizes : size = 16
with this values :
1920x1080
1600x1200
1280x960
1280x768
1280x720
1024x768
......... and soon
So it proved that the index 0 of the supportedPreviewSizes is smaller than supplied value in this line
params.setPreviewSize(previewSize.width, previewSize.height);
The solution was easy : I changed the supplied value from the index 0 of supportedPreviewSizes so the line will be
params.setPreviewSize(supportedPreviewSizes.get(0).width,
supportedPreviewSizes.get(0).height);
and overall method will be like this
@UiThread
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(camera != null) {
if (!supportedPreviewSizes.isEmpty()){
this.cameraWidth = width;
this.cameraHeight = height;
To Everyone who's facing this problem :
Process: com.androidluckyguys, PID: 6480
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:2034)
at com.androidluckyguys.ARCamera.surfaceChanged(ARCamera.java:215)
at android.view.SurfaceView.updateWindow(SurfaceView.java:634)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:161)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2265)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1286)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6536)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:619)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
I solved the problem when the preview camera doesn't show up and being force closed.
I tried with high end LG devices and debug the ARCamera code to verify some values related to dimension supported.
I start with finding the preview value for width and height from surfaceChanged() :
I got the supplied value was 1440 for width and 2072 for height. And this is the problem, the dimension supplied was too big and
not supported by the device itself. So I compared with the received value in supportPreviewSizes and I got :
SupportedPreviewSizes : size = 16
with this values :
1920x1080
1600x1200
1280x960
1280x768
1280x720
1024x768
......... and soon
So it proved that the index 0 of the supportedPreviewSizes is smaller than supplied value in this line
params.setPreviewSize(previewSize.width, previewSize.height);
The solution was easy : I changed the supplied value from the index 0 of supportedPreviewSizes so the line will be
params.setPreviewSize(supportedPreviewSizes.get(0).width,
supportedPreviewSizes.get(0).height);
and overall method will be like this
@UiThread
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(camera != null) {
if (!supportedPreviewSizes.isEmpty()){
this.cameraWidth = width;
this.cameraHeight = height;
The text was updated successfully, but these errors were encountered: