brownemint / Ti-Android-CameraView

MIT License
23 stars 15 forks source link

exception on thread: main msg:java.lang.NullPointerException: Attempt to read from field 'int android.hardware.Camera$Size.width #9

Closed brownemint closed 8 years ago

brownemint commented 9 years ago

From Pull Request

I'm currently using your Ti-Android-CameraView for my appcelerator project, i tried to using your CameraViewProxy.java source code and doing some changes to match with my project, but it shows an error. (Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to read from field 'int android.hardware.Camera$Size.width') Can you please give me some advice or can you share with me your java source code?

Thank you very much, hope to get your reply soon.

Chris Pang (chrispangmq1989@gmail.com)

brownemint commented 8 years ago

Version 0.6.3 should fix this bug. The problem is due to the restarting the preview. A solution that works is to set the pictureTimeout argument to 0 or use a lower resolution. See the Readme for instructions on how to do this.

cdrx commented 8 years ago

I still get this error on some devices.

[INFO]  CameraViewProxy: Opening Camera
[INFO]  CameraViewProxy: Using Back Camera
[INFO]  CameraViewProxy: Setting Preview Display
[INFO]  CameraViewProxy: Trying to match screen resolution for picture
[WARN]  W/System.err: java.lang.NullPointerException: Attempt to read from field 'int android.hardware.Camera$Size.width' on a null object reference
[WARN]  W/System.err:   at pw.custom.androidcamera.CameraViewProxy$CameraView.surfaceCreated(CameraViewProxy.java:169)
[WARN]  W/System.err:   at android.view.SurfaceView.updateWindow(SurfaceView.java:582)
[WARN]  W/System.err:   at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
[WARN]  W/System.err:   at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
[WARN]  W/System.err:   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
[WARN]  W/System.err:   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
[WARN]  W/System.err:   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
[WARN]  W/System.err:   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
[WARN]  W/System.err:   at android.view.Choreographer.doCallbacks(Choreographer.java:670)
[WARN]  W/System.err:   at android.view.Choreographer.doFrame(Choreographer.java:606)
[WARN]  W/System.err:   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
[WARN]  W/System.err:   at android.os.Handler.handleCallback(Handler.java:739)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:148)
[WARN]  W/System.err:   at android.app.ActivityThread.main(ActivityThread.java:5417)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Native Method)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
[INFO]  CameraViewProxy: Starting Preview

This is on a Nexus 5X, with the resolution set to screen size. The camera view does display and work, but the image is rotated 90 degrees in the wrong direction. On other devices (Galaxy S4, for example) the exact same code works fine and the image has the same orientation.

cenfei commented 6 years ago

Hello,can you help me? i got the same error with a vivo Y51n Android5.1.1 the log is: W/System.err: java.lang.NullPointerException: Attempt to read from field 'int android.hardware.Camera$Size.width' on a null object reference

please give me some idea. how to resolve the problem ? thank you