Compressor
Compressor copied to clipboard
Android 11 - open failed: EACCES (Permission denied)
- I have already added
requestLegacyExternalStoragewhich does not work SDK > 29 - User gives permission to write to storage but the problem here is the library is trying to write somewhere else for compression which is not allowed android 11 onwards.
Exception -
kotlin.io.FilesKt__UtilsKt.copyTo (FilesKt__UtilsKt.java:235)
kotlin.io.FilesKt__UtilsKt.copyTo$default (FilesKt__UtilsKt.java:217)
id.zelory.compressor.UtilKt.copyToCache (UtilKt.java:82)
id.zelory.compressor.Compressor$compress$3.invokeSuspend (Compressor.java:25)
id.zelory.compressor.Compressor$compress$3.invoke (Compressor.java:2)
kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn (UndispatchedKt.java:91)
kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext (BuildersKt__Builders_commonKt.java:165)
kotlinx.coroutines.BuildersKt.withContext (BuildersKt.java:1)
id.zelory.compressor.Compressor.compress (Compressor.java:23)
id.zelory.compressor.Compressor.compress$default (Compressor.java:22)
I am using Library version 3.0.0
How to compress images for Android 10 and above? Can you give me name of some other good library
You cannot use this permission on devices 11+
You can open file to compress by path that provided by URI and then write this file by uri You should get URI by intent like ACTION_GET_CONTENT
can you provide sample code?