CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard...

使用CameraView的时候,部分手机(比如三星部分机型android7.0 8.0系统)出现bug:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.camera2.CameraCaptureSession.capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession$CaptureCallback, android.os.Handler)' on a null object reference

CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard..._第1张图片
image.png

CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard..._第2张图片
image.png

解决办法:CameraView.Callback回调里面最后调用:camera.stop()

参考:https://github.com/google/cameraview/issues/29

CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard..._第3张图片
image.png
CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard..._第4张图片
image.png

你可能感兴趣的:(CameraView之bug:java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hard...)