はじめまして、Android開発の初心者です。
Camera APIを使用していますが、API 28でビルドと下記のエラーが出ました:
E/SurfaceView: Exception configuring surface
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:2102)
at jp.image_management.ui.camera.widget.CameraPreview.updateCameraParameters(CameraPreview.java:314)
at jp.image_management.ui.camera.widget.CameraPreview.surfaceCreated(CameraPreview.java:157)
at android.view.SurfaceView.updateSurface(SurfaceView.java:670)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:143)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2474)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/Camera: Error 2
API28以前ではエラーにはなりません、正常に動作しています。
コードの一部です:
if (mCamera != null) {
Camera.Parameters params = mCamera.getParameters();
setParameters(params);
try {
mCamera.setParameters(params);
} catch (RuntimeException e) {
Camera.Size previewSize = findBestPreviewSize(params);
Camera.Size pictureSize = findPictureSize(params);
params.setPreviewSize(previewSize.width, previewSize.height);
params.setPictureSize(pictureSize.width, pictureSize.height);
//ここでエラーになります(API 28)
mCamera.setParameters(params);
}
}
}
API28で何か変更があるでしょう?よろしくお願いします。