Drjacky / ImagePicker

📸Image Picker for Android, Pick images from Gallery or Capture a new image with Camera🖼
https://github.com/Drjacky/ImagePicker
Apache License 2.0
230 stars 57 forks source link

File Not Found Exception #88

Closed ZoobiApplications closed 1 year ago

ZoobiApplications commented 1 year ago

File not found exception occurs when picking image from gallery in your latest sample app.

Error Snippet:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.github.drjacky.imagepicker.sample, PID: 24962 java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=731911126, result=-1, data=Intent { dat=content://media/picker/0/com.android.providers.media.photopicker/media/1000000299 flg=0x41 clip={image/ video/ {U(content)}} }} to activity {com.github.drjacky.imagepicker.sample/com.github.drjacky.imagepicker.ImagePickerActivity}: java.io.IOException: No such file or directory at android.app.ActivityThread.deliverResults(ActivityThread.java:5946) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5985) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) Caused by: java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively0(Native Method) at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317) at java.io.File.createNewFile(File.java:1006) at com.github.drjacky.imagepicker.provider.CropProvider.convertBitmapToFile(CropProvider.kt:235) at com.github.drjacky.imagepicker.provider.CropProvider.cropImage(CropProvider.kt:166) at com.github.drjacky.imagepicker.provider.CropProvider.startIntent(CropProvider.kt:128) at com.github.drjacky.imagepicker.ImagePickerActivity.setMultipleCropper(ImagePickerActivity.kt:198) at com.github.drjacky.imagepicker.ImagePickerActivity.setMultipleImage(ImagePickerActivity.kt:186) at com.github.drjacky.imagepicker.provider.GalleryProvider.handleResult(GalleryProvider.kt:171) at com.github.drjacky.imagepicker.provider.GalleryProvider.handleResult(GalleryProvider.kt:154) at com.github.drjacky.imagepicker.ImagePickerActivity.galleryLauncher$lambda-0(ImagePickerActivity.kt:54) at com.github.drjacky.imagepicker.ImagePickerActivity.$r8$lambda$-cKXUbSEPsgVWIyQVksiDayv-z4(Unknown Source:0) at com.github.drjacky.imagepicker.ImagePickerActivity$$ExternalSyntheticLambda0.onActivityResult(Unknown Source:4) at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:392) at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:351) at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:647) at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:140) at android.app.Activity.dispatchActivityResult(Activity.java:8659) at android.app.ActivityThread.deliverResults(ActivityThread.java:5939) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5985)  at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54)  at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loopOnce(Looper.java:226)  at android.os.Looper.loop(Looper.java:313)  at android.app.ActivityThread.main(ActivityThread.java:8751)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 

ZoobiApps commented 1 year ago

I tested this sample app yesterday and it was working fine but today it is showing me same exception. Don't know what happened!

ZoobiApps commented 1 year ago

it is not picking the images from recents that are shown for the very first time,... but when we click on browse and select from files it's working fine. Please do let me know if you can solve this or even if you can stop recents to be viewed.

Here are the screenshots.

ashifali3147 commented 1 year ago

I am facing the same issue today.

ZoobiApps commented 1 year ago

@Drjacky ?

ibrahim-sdsol commented 1 year ago

Facing same issue

mandocarrilloh commented 1 year ago

@Drjacky same issue 2 days ago

ashifali3147 commented 1 year ago

Check ImagePicker this library.

ZoobiApplications commented 1 year ago

@Catlandor thankyou so much for the Bugfix.

Drjacky commented 1 year ago

Thanks to @Catlandor, fixed on 2.3.21

Catlandor commented 1 year ago

@Drjacky: Thanks for including my fix, but the changes within the "GalleryProvider" are needed as well. When picking an image with the Android photo picker it treats this as a "multiple image" selection, even though it is not.

If you do not include this change, the returned result for a single image selection via the Android photo picker will be always null (uri of the image).

I also tested my changes with the multiple image selection as well: This still works as intended.

Drjacky commented 1 year ago

Fixed on 2.3.22. Thanks!

oia05 commented 1 year ago

Heyy, I know this is closed, but can I know what are the retro steps? It happened with some of our users, but we did not know when and how. Thanks.

Catlandor commented 1 year ago

It's related to the Android photo picker, which was released with SDK version 33 of Android. Also see: https://developer.android.com/training/data-storage/shared/photopicker

When opening the gallery, the photo picker was opened (instead of the default gallery folder view) and selecting an image with this (new) photo picker had two issues with the previous implementation (release 2.3.20):

Second issue also could been reproduced by opening the gallery, then navigating the Google Photos (via hamburger menu on the top left) and selecting an image from here.

Both issues are fixed with release 2.3.22

oia05 commented 1 year ago

Thank you for the clarification