burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.16k stars 992 forks source link

Not able to save image - Snackbar shows Failed to save #344

Closed abdullah230695 closed 3 years ago

tanoDxyz commented 3 years ago

any additional info :>

abdullah230695 commented 3 years ago

after selecting the image , when I touch download icon it says "Failed to save image" as a snackBar, the image is not getting saved in gallery.

burhanrashid52 commented 3 years ago

Can you please share the stack trace of the error.

abdullah230695 commented 3 years ago

yes see this, Im getting the result in OnFailure method

The log says : java.io.FileNotFoundException: /storage/emulated/0/Pictures/1620045395282.png.jpg: open failed: EACCES (Permission denied)

burhanrashid52 commented 3 years ago

Seems like you did not allow storage permission for the app. Please check and allow the storage permission for the app on setting.

abdullah230695 commented 3 years ago

actually it doesn't ask for write permission when touching download icon and also its not showing storage option in app settings. so I just removed " maxSdkVersion=28 " from manifest now its showing storage permission in app settings and I just enable it manually now its working . I can able to save image. but the problem is its not asking for write permission at first...

abdullah230695 commented 3 years ago

To ask permission I just added the permission this code if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { String[] permission = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; requestPermissions(permission, WRITE_EXTERNAL_STORAGE_CODE); } }

abdullah230695 commented 3 years ago

Anyway you have built a nice project Thankyou so much

burhanrashid52 commented 3 years ago

@tanoDxyz Do you have any input on this ?

tanoDxyz commented 3 years ago

well if @abdullah230695 is running the code on emulator than there is a slight chance that correct code will cause the problem . second the only thing that came up in my mind while seeing this error is that if requestLegacyExternalStorage is used in conjuction with android device that is running android 10 or above - it will cause such error.