CarnegieTechnologies / gallery_saver

Flutter plugin that saves images and videos to devices gallery
Apache License 2.0
157 stars 329 forks source link

java.lang.NullPointerException #161

Open cihadturhan opened 3 years ago

cihadturhan commented 3 years ago

I couldn’t reproduce this on my phone and emulators but this affects my users on google play. Sending stacktrace from gplay console:

Android 8.0 (SDK 26)

java.lang.NullPointerException: 
  at carnegietechnologies.gallery_saver.GallerySaver.access$getActivity$p (GallerySaver.java:2)
  or                     .finishWithSuccess (GallerySaver.java:2)
  at carnegietechnologies.gallery_saver.GallerySaver.access$finishWithSuccess (GallerySaver.java)
  or                     .checkPermissionAndSaveFile$gallery_saver_release (GallerySaver.java)
  or                     .finishWithFailure (GallerySaver.java)
  or                     .onRequestPermissionsResult (GallerySaver.java)
  at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1.invokeSuspend (GallerySaver.java:63)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.create (BaseContinuationImpl.java:10)
  or                     .resumeWith (BaseContinuationImpl.java:10)
  at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.java:93)
  at android.os.Handler.handleCallback (Handler.java:789)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6942)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
cihadturhan commented 3 years ago

@jelenalecic & @lecicdjuro,

I guess these lines causes null pointer exception but I don't have any prior experience with Kotlin. https://github.com/CarnegieTechnologies/gallery_saver/blob/master/android/src/main/kotlin/carnegietechnologies/gallery_saver/GallerySaver.kt#L78-L86

Any guesses why I see this crash?

isiktashamza commented 2 years ago

@jelenalecic & @lecicdjuro,

I guess these lines causes null pointer exception but I don't have any prior experience with Kotlin. https://github.com/CarnegieTechnologies/gallery_saver/blob/master/android/src/main/kotlin/carnegietechnologies/gallery_saver/GallerySaver.kt#L78-L86

Any guesses why I see this crash?

I am facing the same issue here, I guess the problem is that on some phones, callback with native code happens to be null. Changing "!!" to ? will solve the problem but there will be no feedback to indicate whether the operation succeeded or not.

mateuss-silva commented 2 years ago

Same problem, with the same stacktrace and the app crashes.

E/AndroidRuntime(22502): FATAL EXCEPTION: main E/AndroidRuntime(22502): Process: br.com.soupilar.mobile, PID: 22502 E/AndroidRuntime(22502): java.lang.NullPointerException E/AndroidRuntime(22502): at carnegietechnologies.gallery_saver.GallerySaver.finishWithSuccess(GallerySaver.kt:79) E/AndroidRuntime(22502): at carnegietechnologies.gallery_saver.GallerySaver.access$finishWithSuccess(GallerySaver.kt:16) E/AndroidRuntime(22502): at carnegietechnologies.gallery_saver.GallerySaver$saveMediaFile$1.invokeSuspend(GallerySaver.kt:74) E/AndroidRuntime(22502): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/AndroidRuntime(22502): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) E/AndroidRuntime(22502): at android.os.Handler.handleCallback(Handler.java:938) E/AndroidRuntime(22502): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(22502): at android.os.Looper.loop(Looper.java:223) E/AndroidRuntime(22502): at android.app.ActivityThread.main(ActivityThread.java:7656) E/AndroidRuntime(22502): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(22502): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) E/AndroidRuntime(22502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) I/Process (22502): Sending signal. PID: 22502 SIG: 9 Lost connection to device. Exited (sigterm)

idish commented 2 years ago

Facing the same crash too.

tinncdev commented 1 year ago

+1 consider #206, this library is discontinued, right?

enderkoca commented 6 months ago

is there any update ?