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.17k stars 992 forks source link

Android 11 Media Access issue #334

Closed DipakUmrigar closed 3 years ago

DipakUmrigar commented 3 years ago

mPhotoEditor.saveAsFile( ) not working to android 11 device

burhanrashid52 commented 3 years ago

Can you please share the stacktrace?

DipakUmrigar commented 3 years ago

D/PhotoEditor: Failed to save File

On Wed, Apr 7, 2021 at 1:22 PM Burhanuddin Rashid @.***> wrote:

Can you please share the stacktrace?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/burhanrashid52/PhotoEditor/issues/334#issuecomment-814690442, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAGJV52PAXXVPR2WAAR3ZLTHQFNHANCNFSM42QGTKKQ .

DipakUmrigar commented 3 years ago

Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)

On Wed, Apr 7, 2021 at 7:26 PM Dipak Umrigar - Inspiro Infotech < @.***> wrote:

D/PhotoEditor: Failed to save File

On Wed, Apr 7, 2021 at 1:22 PM Burhanuddin Rashid < @.***> wrote:

Can you please share the stacktrace?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/burhanrashid52/PhotoEditor/issues/334#issuecomment-814690442, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAGJV52PAXXVPR2WAAR3ZLTHQFNHANCNFSM42QGTKKQ .

lucianocheng commented 3 years ago

Android 11 (SDK 30) is enforcing scoped storage [1]. Broad file access (even via the requestLegacyExternalStorage) will be deprecated if you target SDK 30 [2]. Developers are beginning to get warnings about it starting May 5 2021 [3]

As far as I know, there's no current way to use PhotoEditor without the app being granted file access. The code would have to be changed to move to scoped storage.

[1] https://developer.android.com/about/versions/11/privacy/storage [2] https://support.google.com/googleplay/android-developer/answer/9956427 [3] https://www.reddit.com/r/androiddev/comments/mqzls8/ominous_scoped_storage_warning_messages/

tanoDxyz commented 3 years ago

I hope @DipakUmrigar you are using File Save Helper declared in the sample app which will save files on all devices but if you are not using that do the following.

1- you had storage permission declared like this
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

2- check out Edit Image Activity that how files are saved.

and if you are already using File Save Helper please post your complete stack trace + your android device name

burhanrashid52 commented 3 years ago

Closing due no activity

TimothyGCY commented 2 years ago

Forgive me if this is improper behaviour to put comment on closed issue. For my case, i used FileSaveHelper and it happens almost all devices are able to save images with it, but so far I only noticed this device: Huawei P30 (Android 10) will still prompt the error.

So far I have tested on Android Emulator (Android 8, 9) and Realme C21 & Oneplus 8 (Android 11)

W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Pictures/1637544400195.png.jpg: open failed: EACCES (Permission denied) W/System.err: at libcore.io.IoBridge.open(IoBridge.java:496) W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:235) W/System.err: at ja.burhanrashid52.photoeditor.PhotoSaverTask.saveImageInFile(PhotoSaverTask.java:86) W/System.err: at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:70) W/System.err: at ja.burhanrashid52.photoeditor.PhotoSaverTask.doInBackground(PhotoSaverTask.java:23) W/System.err: at android.os.AsyncTask$3.call(AsyncTask.java:389) W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:292) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err: at java.lang.Thread.run(Thread.java:929) W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) W/System.err: at libcore.io.Linux.open(Native Method) W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:167) W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252) W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:167) W/System.err: at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8242) W/System.err: at libcore.io.IoBridge.open(IoBridge.java:482) W/System.err: ... 10 more