CameraX: NullPointerException when trying to record video
See original GitHub issueI have a simple video recording app set up like this:
VideoCaptureConfig videoCaptureConfig = new VideoCaptureConfig.Builder()
.setLensFacing(CameraX.LensFacing.BACK)
.setTargetAspectRatio(new Rational(16, 9))
.setTargetRotation(viewFinder.getDisplay().getRotation())
.build();
videoCapture = new VideoCapture(videoCaptureConfig);
CameraX.bindToLifecycle(this, preview, videoCapture);
…
videoCapture.startRecording(file, new VideoCapture.OnVideoSavedListener() { ... });
which leads to the following NullPointerException:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.AudioRecord.startRecording()' on a null object reference
at androidx.camera.core.VideoCapture.startRecording(VideoCapture.java:262)
at androidx.camera.core.VideoCapture.startRecording(VideoCapture.java:236)
at de.twometer.stream.cam.CameraActivity.lambda$onCreate$1$CameraActivity(CameraActivity.java:77)
at de.twometer.stream.cam.-$$Lambda$CameraActivity$MvEAnqH_74mMgbMAcSbB_pNoJ3k.onClick(Unknown Source:4)
at android.view.View.performClick(View.java:7352)
at android.view.View.performClickInternal(View.java:7318)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27807)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7037)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
I am using CameraX version 1.0.0-alpha04
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
CameraX: NullPointerException when trying to record video #50
I have a simple video recording app set up like this: VideoCaptureConfig videoCaptureConfig = new VideoCaptureConfig.Builder() .
Read more >NullPointerException in codelabs Android CameraX tutorial ...
This null pointer exception normally occurs when permissions are not declared properly in AndroidManifest.xml . There doesn't seem to be an ...
Read more >CameraX crash on ImageCapture.takePhoto() [230454568]
The error means the app take picture after lifecycle goes to stop or ImageCapture is unbound, which is not a valid operation for...
Read more >Issue with a video capture : NullPointerException
Hello ! I Want to use a sketch running an EXTERNE webcam (a logitech 310c). The sketch runs perfectly well with the built-in...
Read more >CameraX | Android Developers
Fixed NullPointerException/Surface Abandoned error occurring on some devices when quickly taking photos while unbinding and rebinding use cases rapidly. Fixed ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nevermind, I am just stupid and forgot to request audio permission.
androidx.camera.video.VideoCapture
should not require the audio permission unless you callPendingRecording.withAudioEnabled()
.Please see this guide on how to use the new VideoCapture API.