flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.14k stars 27.47k forks source link

[image_picker] Cannot select an image from Google Photos #17165

Closed amg1983 closed 3 years ago

amg1983 commented 6 years ago

Steps to Reproduce

  1. Click on "Pick Image from Gallery" in my app. The next command is executed: var file = await ImagePicker.pickImage(source: ImageSource.gallery, maxWidth: 1024.0, maxHeight: 1024.0);
  2. A new window with my recent photos is opened.
  3. Open drawer menu and click on Google Photos
  4. I select one of my photos stored on my account.
  5. My flutter app crashes

Note: everything works normally when I choose a local image

Logs

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

Run your application with flutter run and attach all the log output.

logs ```bash V/FA ( 1524): Recording user engagement, ms: 22968 V/FA ( 1524): Connecting to remote service V/FA ( 1524): Activity paused, time: 271476005 D/FA ( 1524): Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=22968, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=1782557962679032650}] V/FA ( 1524): Connection attempt already in progress D/FA ( 1524): Connected to remote service V/FA ( 1524): Processing queued up service tasks: 2 V/FA ( 1524): Activity resumed, time: 271477878 I/FlutterActivityDelegate( 1524): onResume setting current activity to this V/FA ( 1524): Screen exposed for less than 1000 ms. Event not sent. time: 23 V/FA ( 1524): Activity paused, time: 271477900 V/FA ( 1524): Inactivity, disconnecting from the service I/FirebaseAuth( 1524): [FirebaseAuth:] Loading module via FirebaseOptions. I/FirebaseAuth( 1524): [FirebaseAuth:] Preparing to create service connection to gms implementation E/BitmapFactory( 1524): Unable to decode stream: java.lang.NullPointerException D/AndroidRuntime( 1524): Shutting down VM E/AndroidRuntime( 1524): FATAL EXCEPTION: main E/AndroidRuntime( 1524): Process: es.amg.theartistflutter, PID: 1524 E/AndroidRuntime( 1524): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/1/1/mediakey:/local%3A0716a35f-1297-473e-9232-1bf173874512/ORIGINAL/NONE/1802626355 flg=0x1 clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/1/1/mediakey%3A%2Flocal%253A0716a35f-1297-473e-9232-1bf173874512/ORIGINAL/NONE/1802626355} }} to activity {es.amg.theartistflutter/es.amg.theartistflutter.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference E/AndroidRuntime( 1524): at android.app.ActivityThread.deliverResults(ActivityThread.java:4268) E/AndroidRuntime( 1524): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312) E/AndroidRuntime( 1524): at android.app.ActivityThread.-wrap19(Unknown Source:0) E/AndroidRuntime( 1524): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644) E/AndroidRuntime( 1524): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime( 1524): at android.os.Looper.loop(Looper.java:164) E/AndroidRuntime( 1524): at android.app.ActivityThread.main(ActivityThread.java:6494) E/AndroidRuntime( 1524): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 1524): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) E/AndroidRuntime( 1524): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) E/AndroidRuntime( 1524): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference E/AndroidRuntime( 1524): at io.flutter.plugins.imagepicker.ImageResizer.resizedImage(ImageResizer.java:48) E/AndroidRuntime( 1524): at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded(ImageResizer.java:37) E/AndroidRuntime( 1524): at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleResult(ImagePickerDelegate.java:262) E/AndroidRuntime( 1524): at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChoosePictureResult(ImagePickerDelegate.java:230) E/AndroidRuntime( 1524): at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult(ImagePickerDelegate.java:217) E/AndroidRuntime( 1524): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:194) E/AndroidRuntime( 1524): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:139) E/AndroidRuntime( 1524): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:128) E/AndroidRuntime( 1524): at android.app.Activity.dispatchActivityResult(Activity.java:7266) E/AndroidRuntime( 1524): at android.app.ActivityThread.deliverResults(ActivityThread.java:4264) E/AndroidRuntime( 1524): ... 9 more ```

Run flutter analyze and attach any output of that command also.

logs ```bash hint • Unused import: 'dart:math' at lib/data/FirebaseDb.dart:3:8 • unused_import hint • Unused import: 'dart:io' at lib/data/FirebaseDb.dart:13:8 • unused_import hint • Unused import: 'package:the_artist_flutter/views/ArtistView.dart' at lib/main.dart:4:8 • unused_import hint • Unused import: 'package:fluro/fluro.dart' at lib/main.dart:6:8 • unused_import hint • Unused import: 'package:the_artist_flutter/data/FirebaseDb.dart' at lib/models/AppState.dart:3:8 • unused_import hint • The value of the local variable 'photoUrl' isn't used at lib/views/MainView.dart:75:9 • unused_local_variable hint • Unused import: 'package:cached_network_image/cached_network_image.dart' at lib/views/ProfileEditionView.dart:4:8 • unused_import hint • Unused import: 'package:the_artist_flutter/models/Picture.dart' at lib/views/ProfileEditionView.dart:9:8 • unused_import hint • Unused import: 'package:meta/meta.dart' at lib/widgets/CachedImage.dart:4:8 • unused_import 9 issues found. ```

Flutter Doctor

Paste the output of running flutter doctor -v here.

flutter doctor -v ```bash [✓] Flutter (Channel dev, v0.3.2, on Mac OS X 10.13.4 17E199, locale es-ES) • Flutter version 0.3.2 at /Users/antonio/Programming/flutter • Framework revision 44b7e7d3f4 (12 days ago), 2018-04-20 01:02:44 -0700 • Engine revision 09d05a3891 • Dart version 2.0.0-dev.48.0.flutter-fe606f890b [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) • Android SDK at /Users/antonio/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-27, build-tools 27.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01) • All Android licenses accepted. [✓] iOS toolchain - develop for iOS devices (Xcode 9.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.3, Build version 9E145 • ios-deploy 1.9.2 • CocoaPods version 1.4.0 [✓] Android Studio (version 3.1) • Android Studio at /Applications/Android Studio 2.app/Contents • Flutter plugin version 24.0.1 • Dart plugin version 173.4700 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01) [✓] Android Studio (version 3.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 24.0.1 • Dart plugin version 173.4700 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01) [✓] IntelliJ IDEA Community Edition (version 2018.1.1) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 23.2.3 • Dart plugin version 181.4445.29 [✓] VS Code • VS Code at /Applications/Visual Studio Code.app/Contents • Dart Code extension version 2.11.2 [✓] Connected devices (1 available) • Nexus 6P • ENU5T15B12002052 • android-arm64 • Android 8.1.0 (API 27) • No issues found! ```
goderbauer commented 6 years ago

There's a PR our for review that sounds like it might fix this: https://github.com/flutter/plugins/pull/513.

dpasqualin commented 6 years ago

Same problem here, but different error message:

logs ```bash E/flutter (10580): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (10580): NoSuchMethodError: The getter 'absolute' was called on null. E/flutter (10580): Receiver: null E/flutter (10580): Tried calling: absolute E/flutter (10580): #0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46) E/flutter (10580): #1 StorageFileUploadTask._start (package:firebase_storage/src/upload_task.dart:33:27) E/flutter (10580): E/flutter (10580): #2 StorageReference.putFile (package:firebase_storage/src/storage_reference.dart:63:10) E/flutter (10580): #3 ChatRoomState._buildTextComposer. (/data/user/0/nl.fael.advogapp.app/cache/appCCUMKX/app/lib/chatroom.dart:141:56) E/flutter (10580): E/flutter (10580): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:494:14) E/flutter (10580): #5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:549:30) E/flutter (10580): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) E/flutter (10580): #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9) E/flutter (10580): #8 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7) E/flutter (10580): #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9) E/flutter (10580): #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12) E/flutter (10580): #11 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11) E/flutter (10580): #12 BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19) E/flutter (10580): #13 BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22) E/flutter (10580): #14 BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7) E/flutter (10580): #15 BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7) E/flutter (10580): #16 BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7) E/flutter (10580): #17 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:134) E/flutter (10580): #18 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:91) D/EGL_emulation(10580): eglCreateContext: 0xaebe2660: maj 2 min 0 rcv 2 D/EGL_emulation(10580): eglMakeCurrent: 0xaebe2660: ver 2 0 (tinfo 0x91bf5480) D/EGL_emulation(10580): eglMakeCurrent: 0xa6f051e0: ver 2 0 (tinfo 0xa6f033f0) D/EGL_emulation(10580): eglMakeCurrent: 0xaebe2660: ver 2 0 (tinfo 0xa6f03380) ```
cyanglaz commented 5 years ago

Seems that https://github.com/flutter/plugins/pull/513 is merged. @amg1983 Is this issue fixed after the patch?

tecbot commented 5 years ago

@cyanglaz The issue still exists with 0.5.3:

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/34370/ORIGINAL/NONE/128092117 flg=0x1 launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } clip={text/uri-list U:content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F34370/ORIGINAL/NONE/128092117} }} to activity {de.fastic.app/de.fastic.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at android.app.ActivityThread.deliverResults(ActivityThread.java:4520)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:4563)
       at android.app.ActivityThread.-wrap22(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6776)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
       at io.flutter.plugins.imagepicker.ImageResizer.resizedImage(ImageResizer.java:48)
       at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded(ImageResizer.java:37)
       at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult(ImagePickerDelegate.java:430)
       at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseImageResult(ImagePickerDelegate.java:372)
       at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult(ImagePickerDelegate.java:351)
       at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:222)
       at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:143)
       at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
       at android.app.Activity.dispatchActivityResult(Activity.java:7280)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:4516)
       at android.app.ActivityThread.handleSendResult(ActivityThread.java:4563)
       at android.app.ActivityThread.-wrap22(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6776)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

Device Info:

Model: Samsung Galaxy A5(2016)
Free RAM: 282.8 MB
Free Space: 1017.56 MB
Android Version: 7.0
[✓] Flutter (Channel master, v1.4.15-pre.3, on Mac OS X 10.14.4 18E226, locale de-DE)
    • Flutter version 1.4.15-pre.3
    • Framework revision 421f16a6b9 (vor 11 Tagen), 2019-04-09 23:15:18 -0400
    • Engine revision 905c571db5
    • Dart version 2.2.1 (build 2.2.1-dev.3.1 None)
no-response[bot] commented 5 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

tecbot commented 5 years ago

Please reopen, see comment above.

cyanglaz commented 5 years ago

Reopening for further investigation.

no-response[bot] commented 5 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

tecbot commented 5 years ago

@cyanglaz the no-response bot closed this issue again :(

cyanglaz commented 5 years ago

@tecbot I tried some of my devices and couldn't reproduce the issue. Is this issue only happening on your Samsung Galaxy A5(2016) or it happens on different devices as well>? Could you provide info for other devices which you experience the issue on?

tecbot commented 5 years ago

@cyanglaz Unfortunately , the exception was recored with Firebase Crashlytics from a customer, I can't reproduce it neither with my android test devices. It's also the only device with this exception, currently.

cyanglaz commented 5 years ago

@tecbot I am still waiting to get the test device to reproduce the issue. But I think https://github.com/flutter/plugins/pull/1541 might fix the issue. Could you update the image picker to 0.6.0+1 or apply this patch to see if it fixes your issue?

cyanglaz commented 5 years ago

I eventually got a Samsung Galaxy A5(2016) device and still couldn't reproduce the issue. I am not able to actively work on this recently. I will un-assign myself from this issue. Feel free to pick this up if anyone is interested!

josh-burton commented 5 years ago

I am getting this issue on 2 Android 10 devices.

JCFlores93 commented 5 years ago

The same for me on xiaomi redmi 6a.

mustafabhatkar commented 5 years ago

Yes I had this crash too on Oneplus 7T with Android 10

Caused by: java.lang.NullPointerException: at io.flutter.plugins.imagepicker.ImageResizer.resizedImage (ImageResizer.java:6) at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded (ImageResizer.java:18) at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult (ImagePickerDelegate.java:49) at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseImageResult (ImagePickerDelegate.java:18) at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult (ImagePickerDelegate.java:30) at io.flutter.app.FlutterPluginRegistry.onActivityResult (FlutterPluginRegistry.java:18) at io.flutter.app.FlutterActivityDelegate.onActivityResult (FlutterActivityDelegate.java:6) at io.flutter.app.FlutterActivity.onActivityResult (FlutterActivity.java:2)

Minituff commented 5 years ago

I am able to reproduce this on my OnePlus 6t. The image I am choosing is a .webp - 696x597 This code works on other images, but crashes 100% of the time when I choose this image.

Flutter Code:

/// Select an image via gallery or camera
  Future<void> _pickImage(ImageSource source) async {
    File selected = await ImagePicker.pickImage(source: source);
    setState(() => _imageFile = selected);
  }

Crash:

E/AndroidRuntime(15575):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15575):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
E/AndroidRuntime(15575):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(15575): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime(15575):    at io.flutter.plugins.imagepicker.ImageResizer.resizedImage(ImageResizer.java:52)
E/AndroidRuntime(15575):    at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded(ImageResizer.java:40)
E/AndroidRuntime(15575):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult(ImagePickerDelegate.java:530)
E/AndroidRuntime(15575):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseImageResult(ImagePickerDelegate.java:463)
E/AndroidRuntime(15575):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult(ImagePickerDelegate.java:442)
E/AndroidRuntime(15575):    at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:204)
E/AndroidRuntime(15575):    at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:132)
E/AndroidRuntime(15575):    at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime(15575):    at android.app.Activity.dispatchActivityResult(Activity.java:7476)
E/AndroidRuntime(15575):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
E/AndroidRuntime(15575):    ... 11 more
W/OPDiagnose(15575): getService:OPDiagnoseService NULL
D/OSTracker(15575): OS Event: crash
I/Process (15575): Sending signal. PID: 15575 SIG: 9
Lost connection to device.
Exited (sigterm)

And another:

E/BitmapFactory(16868): Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/android/data/com.XXX.XXX/files/Pictures/scaled_nf.webp (No such file or directory)
D/AndroidRuntime(16868): Shutting down VM
E/AndroidRuntime(16868): FATAL EXCEPTION: main
E/AndroidRuntime(16868): Process: com.XXX.XXX, PID: 16868
E/AndroidRuntime(16868): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:43537 flg=0x1 }} to activity {com.XXX.XXX/com.example.XXX.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime(16868):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4496)
E/AndroidRuntime(16868):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
E/AndroidRuntime(16868):    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
E/AndroidRuntime(16868):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime(16868):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime(16868):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
E/AndroidRuntime(16868):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(16868):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(16868):    at android.app.ActivityThread.main(ActivityThread.java:6863)
E/AndroidRuntime(16868):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16868):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
E/AndroidRuntime(16868):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime(16868): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime(16868):    at io.flutter.plugins.imagepicker.ImageResizer.resizedImage(ImageResizer.java:52)
E/AndroidRuntime(16868):    at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded(ImageResizer.java:40)
E/AndroidRuntime(16868):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult(ImagePickerDelegate.java:530)
E/AndroidRuntime(16868):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseImageResult(ImagePickerDelegate.java:463)
E/AndroidRuntime(16868):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult(ImagePickerDelegate.java:442)
E/AndroidRuntime(16868):    at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:204)
E/AndroidRuntime(16868):    at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:132)
E/AndroidRuntime(16868):    at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime(16868):    at android.app.Activity.dispatchActivityResult(Activity.java:7476)
E/AndroidRuntime(16868):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
E/AndroidRuntime(16868):    ... 11 more
W/OPDiagnose(16868): getService:OPDiagnoseService NULL
D/OSTracker(16868): OS Event: crash
D/AbstractTracker(16868): Event success
I/Process (16868): Sending signal. PID: 16868 SIG: 9
Lost connection to device.
Exited (sigterm)
mustafabhatkar commented 5 years ago

I was able to stop the crash by setting the target SDK to 28 from 29

Minituff commented 5 years ago

@mustafabhatkar Here are my current SDK targets at android\app\build.gradle:

mustafabhatkar commented 5 years ago

Hey, I just tried picking up a webp image on my Oneplus 5 running android 9. I didn't get any crash! try using the latest version of the image picker plugin

Minituff commented 5 years ago

@mustafabhatkar Thanks for the response. I just updated from image_picker: ^0.6.1+4 to image_picker: ^0.6.1+8. I did a flutter clean and ran it again, but I am still having the same issue.

Minituff commented 5 years ago

@mustafabhatkar I read your previous comment completely backwards. So, I just updated the targetSdkVersion to 29 and it seems to be working for now! That same image that was causing the crash before is now working. Thank you so much!

mustafabhatkar commented 5 years ago

Great! be sure to test it out on android 10, especially on Oneplus 7t. I was facing the crash on this particular device running android 10.

Minituff commented 5 years ago

Looks like the same issue is back. Even on API level 29:

E/BitmapFactory( 4480): Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.google.android.gm/cache/39804ef81b6e5a258a35259cef5cd358 (No such file or directory)
D/AndroidRuntime( 4480): Shutting down VM
E/AndroidRuntime( 4480): FATAL EXCEPTION: main
E/AndroidRuntime( 4480): Process: com.xxx.xxx, PID: 4480
E/AndroidRuntime( 4480): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2342, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:43659 flg=0x1 }} to activity {com.xxx.xxx/com.example.xxx.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime( 4480):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4496)
E/AndroidRuntime( 4480):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4538)
E/AndroidRuntime( 4480):    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
E/AndroidRuntime( 4480):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/AndroidRuntime( 4480):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/AndroidRuntime( 4480):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
E/AndroidRuntime( 4480):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 4480):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime( 4480):    at android.app.ActivityThread.main(ActivityThread.java:6863)
E/AndroidRuntime( 4480):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 4480):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
E/AndroidRuntime( 4480):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/AndroidRuntime( 4480): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
E/AndroidRuntime( 4480):    at io.flutter.plugins.imagepicker.ImageResizer.resizedImage(ImageResizer.java:52)
E/AndroidRuntime( 4480):    at io.flutter.plugins.imagepicker.ImageResizer.resizeImageIfNeeded(ImageResizer.java:40)
E/AndroidRuntime( 4480):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult(ImagePickerDelegate.java:530)
E/AndroidRuntime( 4480):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleChooseImageResult(ImagePickerDelegate.java:463)
E/AndroidRuntime( 4480):    at io.flutter.plugins.imagepicker.ImagePickerDelegate.onActivityResult(ImagePickerDelegate.java:442)
E/AndroidRuntime( 4480):    at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:204)
E/AndroidRuntime( 4480):    at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:132)
E/AndroidRuntime( 4480):    at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime( 4480):    at android.app.Activity.dispatchActivityResult(Activity.java:7476)
E/AndroidRuntime( 4480):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
E/AndroidRuntime( 4480):    ... 11 more
W/OPDiagnose( 4480): getService:OPDiagnoseService NULL
E/CrashlyticsCore( 4480): Error occurred sending report com.crashlytics.android.core.SessionReport@315e07
D/OSTracker( 4480): OS Event: crash
I/Process ( 4480): Sending signal. PID: 4480 SIG: 9
Lost connection to device.
Exited (sigterm)
darshankawar commented 3 years ago

Verified this issue using image_picker plugin example on latest stable and on Samsung S10 device. Selected Google Photos option from drawer menu, selected an image which properly displayed on app screen without any issues. I also tested by providing maxWidth and maxHeight as 1024 which worked as expected.

https://user-images.githubusercontent.com/67046386/107223574-5b766580-6a3c-11eb-8b26-a975f5456cdb.mp4

flutter doctor -v ``` [✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.4 19E2269 darwin-x64, locale en-IN) • Flutter version 1.22.6 at /Users/dhs/documents/Fluttersdk/flutter • Framework revision 9b2d32b605 (2 weeks ago), 2021-01-22 14:36:39 -0800 • Engine revision 2f0af37152 • Dart version 2.10.5 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0) • Android SDK at /Users/dhs/Library/Android/sdk • Platform android-30, build-tools 30.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.3, Build version 12C33 • CocoaPods version 1.9.3 [!] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.52.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.18.1 [✓] Connected device (2 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29) • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) ! Doctor found issues in 1 category. ```
console log ``` D/ViewRootImpl@e545666[FlutterActivity](30509): ViewPostIme pointer 0 D/ViewRootImpl@e545666[FlutterActivity](30509): ViewPostIme pointer 1 D/ViewRootImpl@e545666[FlutterActivity](30509): ViewPostIme pointer 0 D/ViewRootImpl@e545666[FlutterActivity](30509): ViewPostIme pointer 1 D/ViewRootImpl@e545666[FlutterActivity](30509): MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager(30509): prepareNavigationBarInfo() DecorView@e3757bc[FlutterActivity] D/InputMethodManager(30509): getNavigationBarColor() -855310 D/InputTransport(30509): Input channel destroyed: 'ClientS', fd=95 D/SurfaceView(30509): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/SurfaceView(30509): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} I/mali_egl(30509): eglDestroySurface() in I/mali_winsys(30509): delete_surface() [1080x2154] return I/mali_egl(30509): eglDestroySurface() out W/libEGL (30509): EGLNativeWindowType 0x77aad3e010 disconnect failed D/SurfaceView(30509): remove() io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} Surface(name=SurfaceView - io.flutter.plugins.imagepicker.example/io.flutter.embedding.android.FlutterActivity@8f8e254@2)/@0x978419e D/OpenGLRenderer(30509): makeCurrent EglSurface : 0x7851354a80 -> 0x0 D/OpenGLRenderer(30509): destroyEglSurface : 0x7851354a80 I/mali_egl(30509): eglDestroySurface() in I/mali_winsys(30509): delete_surface() [1080x2280] return I/mali_egl(30509): eglDestroySurface() out W/libEGL (30509): EGLNativeWindowType 0x78dff3e810 disconnect failed D/OpenGLRenderer(30509): ~ReliableSurface : 0x78dff3e800 D/ViewRootImpl@e545666[FlutterActivity](30509): Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)8 dur=5 res=0x5 s={false 0} ch=true D/ViewRootImpl@e545666[FlutterActivity](30509): stopped(true) old=false D/SurfaceView(30509): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/SurfaceView(30509): onWindowVisibilityChanged(4) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/ViewRootImpl@e545666[FlutterActivity](30509): Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)4 dur=10 res=0x1 s={false 0} ch=false D/ViewRootImpl@e545666[FlutterActivity](30509): stopped(false) old=true D/SurfaceView(30509): windowStopped(false) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/ViewRootImpl@e545666[FlutterActivity](30509): stopped(false) old=false D/SurfaceView(30509): onWindowVisibilityChanged(0) true io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/ViewRootImpl@e545666[FlutterActivity](30509): Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)0 dur=3 res=0x7 s={true 513967116288} ch=true D/OpenGLRenderer(30509): createReliableSurface : 0x78dff3e800(0x77aad3d000) I/mali_winsys(30509): new_window_surface() [1080x2280] return: 0x3000 D/SurfaceView(30509): surfaceCreated 1 #8 io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} I/mali_winsys(30509): new_window_surface() [1080x2154] return: 0x3000 D/SurfaceView(30509): surfaceChanged (1080,2154) 1 #8 io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} D/OpenGLRenderer(30509): makeCurrent EglSurface : 0x0 -> 0x7851354a80 D/ViewRootImpl@e545666[FlutterActivity](30509): MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager(30509): prepareNavigationBarInfo() DecorView@e3757bc[FlutterActivity] D/InputMethodManager(30509): getNavigationBarColor() -855310 D/InputMethodManager(30509): prepareNavigationBarInfo() DecorView@e3757bc[FlutterActivity] D/InputMethodManager(30509): getNavigationBarColor() -855310 V/InputMethodManager(30509): Starting input: tba=io.flutter.plugins.imagepicker.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager(30509): startInputInner - Id : 0 I/InputMethodManager(30509): startInputInner - mService.startInputOrWindowGainedFocus D/ViewRootImpl@e545666[FlutterActivity](30509): MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager(30509): prepareNavigationBarInfo() DecorView@e3757bc[FlutterActivity] D/InputMethodManager(30509): getNavigationBarColor() -855310 D/InputTransport(30509): Input channel destroyed: 'ClientS', fd=97 D/SurfaceView(30509): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] D/SurfaceView(30509): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} I/mali_egl(30509): eglDestroySurface() in I/mali_winsys(30509): delete_surface() [1080x2154] return I/mali_egl(30509): eglDestroySurface() out W/libEGL (30509): EGLNativeWindowType 0x7844fa5010 disconnect failed D/SurfaceView(30509): remove() io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} Surface(name=SurfaceView - io.flutter.plugins.imagepicker.example/io.flutter.embedding.android.FlutterActivity@8f8e254@3)/@0xb864e4e D/OpenGLRenderer(30509): makeCurrent EglSurface : 0x7851354a80 -> 0x0 D/OpenGLRenderer(30509): destroyEglSurface : 0x7851354a80 I/mali_egl(30509): eglDestroySurface() in I/mali_winsys(30509): delete_surface() [1080x2280] return I/mali_egl(30509): eglDestroySurface() out W/libEGL (30509): EGLNativeWindowType 0x78dff3e810 disconnect failed D/OpenGLRenderer(30509): ~ReliableSurface : 0x78dff3e800 D/ViewRootImpl@e545666[FlutterActivity](30509): Relayout returned: old=(0,0,1080,2280) new=(0,0,1080,2280) req=(1080,2280)8 dur=4 res=0x5 s={false 0} ch=true D/ViewRootImpl@e545666[FlutterActivity](30509): stopped(true) old=false D/SurfaceView(30509): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{8f8e254 V.E...... ........ 0,0-1080,2154} of ViewRootImpl@e545666[FlutterActivity] ```

Closing this as not reproducible and probably fixed in latest plugin version. If anybody disagrees, write in comments and I'll reopen it.

github-actions[bot] commented 3 years ago

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.