Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullpointer exception for cameraInstance #108

Closed
aaqibkhan opened this issue Dec 5, 2015 · 12 comments · Fixed by #133
Closed

Nullpointer exception for cameraInstance #108

aaqibkhan opened this issue Dec 5, 2015 · 12 comments · Fixed by #133
Assignees

Comments

@aaqibkhan
Copy link

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.journeyapps.barcodescanner.camera.CameraInstance.setSurfaceHolder(android.view.SurfaceHolder)' on a null object reference
       at com.journeyapps.barcodescanner.CameraPreview.startCameraPreview(CameraPreview.java:472)
       at com.journeyapps.barcodescanner.CameraPreview.startPreviewIfReady(CameraPreview.java:320)
       at com.journeyapps.barcodescanner.CameraPreview.access$200(CameraPreview.java:48)
       at com.journeyapps.barcodescanner.CameraPreview$1.surfaceChanged(CameraPreview.java:130)
       at android.view.SurfaceView.updateWindow(SurfaceView.java:590)
       at android.view.SurfaceView.setFrame(SurfaceView.java:300)
       at android.view.View.layout(View.java:15610)
       at com.journeyapps.barcodescanner.CameraPreview.onLayout(CameraPreview.java:337)
       at android.view.View.layout(View.java:15614)
       at android.view.ViewGroup.layout(ViewGroup.java:4968)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
       at android.view.View.layout(View.java:15614)
       at android.view.ViewGroup.layout(ViewGroup.java:4968)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
       at android.widget.ScrollView.onLayout(ScrollView.java:1505)
       at android.view.View.layout(View.java:15614)
       at android.view.ViewGroup.layout(ViewGroup.java:4968)
@rkistner
Copy link
Member

rkistner commented Dec 6, 2015

Can you please give some more info? See CONTRIBUTING.md.

@aaqibkhan
Copy link
Author

@rkistner
I am using these versions

compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
compile 'com.google.zxing:core:3.2.0'

Device: Moto E2
Android version: 5.0.2

I am not able to reproduce the error. I have used the library many times with above version and it never crashed. Just this one time I got this error.

@aaqibkhan
Copy link
Author

I am calling resume() in activity's onResume() and pause()' inonPause()`.
Using continuous decoding

@rkistner
Copy link
Member

rkistner commented Dec 6, 2015

Thanks, I'll see if I can find the cause.

On Sun, Dec 6, 2015 at 11:24 AM, aaqibkhan notifications@github.com wrote:

I am calling resume() in activity's onResume() and pause()' inonPause()`.
Using continuous decoding


Reply to this email directly or view it on GitHub
#108 (comment)
.

@Sebosam
Copy link

Sebosam commented Dec 29, 2015

Hello,
I think it's because rotation. When u rotate on clean android cameraPreview started faster before finishing stopPreview and then u have only black screen and bug:). It crashed probably in CameraSurface#setPreview. When u minimize app and take it back it start working.
Sorry for language:)

@aaqibkhan
Copy link
Author

any progress on this?

@rkistner
Copy link
Member

rkistner commented Feb 3, 2016

Sorry, no progress yet. Will see if I can do something before the next release.

@matyj
Copy link

matyj commented Feb 4, 2016

any tips or workaround? it's very important for me right now, lib is good but unuseful for me with this error ;<

@Sebosam
Copy link

Sebosam commented Feb 4, 2016 via email

@matyj
Copy link

matyj commented Feb 5, 2016

@Sebosam , what do you mean? i don't understand you at all. in which on pause? what injection do you mean?

@Sebosam
Copy link

Sebosam commented Feb 5, 2016

@matyj Make a second activity to reset ur captureActivty. When u call onPause in captureActivity start the second activity to reset zxing camera and come back to it onTouch event for example(like touch to wake up).

@rkistner
Copy link
Member

rkistner commented Feb 6, 2016

@matyj Can you give more details on how you reproduce this issue and what exactly happens? My initial impression was that this issue was fairly rare and low-impact.

I'm working on a potential fix now, should have it ready soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants