coomar2841 / android-multipicker-library

Android Multipicker Library
Apache License 2.0
438 stars 107 forks source link

Android 11 targetSDK 30 Problem when trying image from gallery or pick file (the play store not submit new apps) #188

Closed rubapigh closed 3 years ago

rubapigh commented 3 years ago

Hi. The play store now not allow upload new versions without targetSdkVersion 30.

When an app is targeting SDK 30 and devices Android 11 the problem occurs.

Library throws exception while selecting image from gallery:

com.kbeanie.multipicker.api.exceptions.PickerException: java.io.FileNotFoundException /.../IMG_20210814_085811.jpg: open failed: ENOENT (No such file or directory)

and when pick a file throws:

com.kbeanie.multipicker.api.exceptions.PickerException: java.io.IOException: Destination '.../sample.pdf' directory cannot be created

Could you find any solution with target SDK 30. Please provide solution. Thank you!

deepbhavsar commented 3 years ago

System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)

I am getting this error.

matale commented 3 years ago

Seems to work if you set the caching method as INTERNAL_APP_DIR. The default and other options seem to check for WRITE EXTERNAL STORAGE permission which you will not have in Android 30.

The issue is that in Android 30 there is no more permission to write to external storage, even if declared it does nothing unless your App has the MANAGE_EXTERNAL_STORAGE permission which is will require manual approval of your App, you will not get this approval in most cases.

While you always have access to internal App storage no permission necessary.

So when you create the picker set the Cache.


 val picker = MediaPicker(this)
 picker.setCacheLocation(CacheLocation.INTERNAL_APP_DIR)
rubapigh commented 3 years ago

@matale thank you very much for your help! you save me!