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

[image_picker] Recording video on Android 13 API 33 fails with java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference #118443

Closed
tomekit opened this issue Jan 13, 2023 · 12 comments
Labels
found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: image_picker The Image Picker plugin. P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: invalid Issue is closed as not valid

Comments

@tomekit
Copy link

tomekit commented Jan 13, 2023

I am using Android Pixel 5 API 33 emulator. When I try to record a video and get the file, just after clicking "stop record" button I get this error:

E/AndroidRuntime(31578): FATAL EXCEPTION: main
E/AndroidRuntime(31578): Process: com.android.camera2, PID: 31578
E/AndroidRuntime(31578): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference
E/AndroidRuntime(31578): 	at com.android.camera.VideoModule.saveVideo(VideoModule.java:1263)
E/AndroidRuntime(31578): 	at com.android.camera.VideoModule.stopVideoRecording(VideoModule.java:1513)
E/AndroidRuntime(31578): 	at com.android.camera.VideoModule.onStopVideoRecording(VideoModule.java:656)
E/AndroidRuntime(31578): 	at com.android.camera.VideoModule.onShutterButtonClick(VideoModule.java:697)
E/AndroidRuntime(31578): 	at com.android.camera.ShutterButton.performClick(ShutterButton.java:190)
E/AndroidRuntime(31578): 	at android.view.View.performClickInternal(View.java:7483)
E/AndroidRuntime(31578): 	at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
E/AndroidRuntime(31578): 	at android.view.View$PerformClick.run(View.java:29334)
E/AndroidRuntime(31578): 	at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(31578): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(31578): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(31578): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(31578): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(31578): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31578): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(31578): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Flutter version

Flutter 3.3.10 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 135454af32 (4 weeks ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0

puspec.yaml

 image_picker: ^0.8.6

pubspec.lock

  image_picker:
    dependency: "direct main"
    description:
      name: image_picker
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.8.6"
  image_picker_android:
    dependency: transitive
    description:
      name: image_picker_android
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.8.5+4"

I can reproduce issue locally.

@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Jan 13, 2023
@exaby73
Copy link
Member

exaby73 commented Jan 13, 2023

Hello @tomekit. Can you provide a complete and minimal, reproducible code sample?

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 13, 2023
@tomekit
Copy link
Author

tomekit commented Jan 13, 2023

Sure, please find this repository which uses default Flutter project with: image_picker added.
https://github.com/tomekit/flutter_issue_video_android33_118443

After clicking the + button, the pickVideo function shall open the camera.
If you stop recording video on Pixel 5 Android 33 emulator you should likely get null in the videoFile, which will then render Snackbar with a failure message.
In some cases I encounter application crash and the Android screen will stay on the camera app being frozen.

If you try to this on e.g. Pixel 5 Android 30 emulator you should get Snackbar showing file location.

Please let me know if this helps. Thanks !

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 13, 2023
@exaby73
Copy link
Member

exaby73 commented Jan 16, 2023

@tomekit I cannot see any stack traces but I do see the video file null. How are you getting the error traces?

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 16, 2023
@tomekit
Copy link
Author

tomekit commented Jan 16, 2023

I am not exactly sure. I wasn't getting it when checked after receiving your comment, but after playing around few times I am getting it consistently.

Screenshot from 2023-01-16 10-12-27

E/AndroidRuntime(11989): FATAL EXCEPTION: main
E/AndroidRuntime(11989): Process: com.android.camera2, PID: 11989
E/AndroidRuntime(11989): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference
E/AndroidRuntime(11989): 	at com.android.camera.VideoModule.saveVideo(VideoModule.java:1263)
E/AndroidRuntime(11989): 	at com.android.camera.VideoModule.stopVideoRecording(VideoModule.java:1513)
E/AndroidRuntime(11989): 	at com.android.camera.VideoModule.onStopVideoRecording(VideoModule.java:656)
E/AndroidRuntime(11989): 	at com.android.camera.VideoModule.onShutterButtonClick(VideoModule.java:697)
E/AndroidRuntime(11989): 	at com.android.camera.ShutterButton.performClick(ShutterButton.java:190)
E/AndroidRuntime(11989): 	at android.view.View.performClickInternal(View.java:7483)
E/AndroidRuntime(11989): 	at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
E/AndroidRuntime(11989): 	at android.view.View$PerformClick.run(View.java:29334)
E/AndroidRuntime(11989): 	at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(11989): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11989): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(11989): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(11989): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(11989): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11989): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(11989): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/SurfaceSyncer(11746): Failed to find sync for id=0
E/SurfaceSyncer(11746): Failed to find sync for id=1
E/SurfaceSyncer(11746): Failed to find sync for id=2
D/EGL_emulation(11746): app_time_stats: avg=265.55ms min=4.15ms max=4019.44ms count=16

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 16, 2023
@exaby73
Copy link
Member

exaby73 commented Jan 16, 2023

So I do reproduce the crash, so to speak but I do not get any logs in the console which is weird. I'll label the issue for further insights from the team

@exaby73 exaby73 added plugin p: image_picker The Image Picker plugin. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 labels Jan 16, 2023
@tomekit
Copy link
Author

tomekit commented Jan 16, 2023

Thanks for the info. By the way, recording video seem to be working fine on a real device, so it seems it is an emulator related issue. It seems similar bug can be found in a different cross-platform framework: react-native-image-picker/react-native-image-picker#2026 (comment)
which makes me actually think that the issue is more related to Android 13 emulator instead of Flutter.

@darshankawar darshankawar added platform-android Android applications specifically and removed in triage Presently being triaged by the triage team labels Jan 18, 2023
@GaryQian

This comment was marked as off-topic.

@GaryQian GaryQian added the P3 Issues that are less important to the Flutter project label Jan 19, 2023
@jpetro416
Copy link

I also have this error when selecting now:

E/AndroidRuntime(19280): FATAL EXCEPTION: main
E/AndroidRuntime(19280): Process: com.android.camera2, PID: 19280
E/AndroidRuntime(19280): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference
E/AndroidRuntime(19280): 	at com.android.camera.VideoModule.saveVideo(VideoModule.java:1263)
E/AndroidRuntime(19280): 	at com.android.camera.VideoModule.stopVideoRecording(VideoModule.java:1513)
E/AndroidRuntime(19280): 	at com.android.camera.VideoModule.onStopVideoRecording(VideoModule.java:656)
E/AndroidRuntime(19280): 	at com.android.camera.VideoModule.onShutterButtonClick(VideoModule.java:697)
E/AndroidRuntime(19280): 	at com.android.camera.ShutterButton.performClick(ShutterButton.java:190)
E/AndroidRuntime(19280): 	at android.view.View.performClickInternal(View.java:7483)
E/AndroidRuntime(19280): 	at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
E/AndroidRuntime(19280): 	at android.view.View$PerformClick.run(View.java:29334)
E/AndroidRuntime(19280): 	at android.os.Handler.handleCallback(Handler.java:942)

@camsim99 camsim99 added this to Camera issues to track in Android Camera Re-write Jan 23, 2023
@saifali25
Copy link

saifali25 commented Feb 14, 2023

Is there any fix to this issue? I am too getting the error:
E/AndroidRuntime(15116): FATAL EXCEPTION: main E/AndroidRuntime(15116): Process: com.android.camera2, PID: 15116 E/AndroidRuntime(15116): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference E/AndroidRuntime(15116): at com.android.camera.VideoModule.saveVideo(VideoModule.java:1263) E/AndroidRuntime(15116): at com.android.camera.VideoModule.stopVideoRecording(VideoModule.java:1513) E/AndroidRuntime(15116): at com.android.camera.VideoModule.onStopVideoRecording(VideoModule.java:656) E/AndroidRuntime(15116): at com.android.camera.VideoModule.onShutterButtonClick(VideoModule.java:697) E/AndroidRuntime(15116): at com.android.camera.ShutterButton.performClick(ShutterButton.java:190) E/AndroidRuntime(15116): at android.view.View.performClickInternal(View.java:7483) E/AndroidRuntime(15116): at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) E/AndroidRuntime(15116): at android.view.View$PerformClick.run(View.java:29334) E/AndroidRuntime(15116): at android.os.Handler.handleCallback(Handler.java:942) E/AndroidRuntime(15116): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(15116): at android.os.Looper.loopOnce(Looper.java:201) E/AndroidRuntime(15116): at android.os.Looper.loop(Looper.java:288) E/AndroidRuntime(15116): at android.app.ActivityThread.main(ActivityThread.java:7872) E/AndroidRuntime(15116): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(15116): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/AndroidRuntime(15116): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

I get this when I try to record a video, the camera opens but when i click on stop recording I get this error in the console.

@TheHudek
Copy link

TheHudek commented Mar 4, 2023

I am getting the same error with the example app as well.

@stuartmorgan
Copy link
Contributor

The image_picker plugin has no control over the camera, it's just requesting that the system launch it via an intent. A crash in the camera is something you would need to report to the developer of the camera application.

@stuartmorgan stuartmorgan closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2023
@stuartmorgan stuartmorgan removed this from Camera issues to track in Android Camera Re-write Mar 4, 2023
@stuartmorgan stuartmorgan changed the title Recording video on Android 13 API 33 fails with java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference [image_picker] Recording video on Android 13 API 33 fails with java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.ContentValues.put(java.lang.String, java.lang.Long)' on a null object reference Mar 4, 2023
@exaby73 exaby73 added the r: invalid Issue is closed as not valid label Mar 6, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2023
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: image_picker The Image Picker plugin. P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: invalid Issue is closed as not valid
Projects
None yet
Development

No branches or pull requests

8 participants