Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 10 devices getting EACCES (Permission denied) #23

Closed
angelkoh opened this issue Jul 20, 2020 · 5 comments
Closed

Android 10 devices getting EACCES (Permission denied) #23

angelkoh opened this issue Jul 20, 2020 · 5 comments
Labels
documentation Improvements or additions to documentation Implemented

Comments

@angelkoh
Copy link

angelkoh commented Jul 20, 2020

your codes uses getExternalStorageDirectory() which will return an exception when we try to run it on Android 10 devices with targetSdkVersion 29.

file with the deprecated code https://github.com/HBiSoft/PickiT/blob/master/pickit/src/main/java/com/hbisoft/pickit/Utils.java

referring to https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()

To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps. Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String), MediaStore, or Intent#ACTION_OPEN_DOCUMENT.

@HBiSoft
Copy link
Owner

HBiSoft commented Jul 20, 2020

Deprecated doesn't mean we can't use it anymore.

In Android 10 file path access was removed and it was returned in Android 11.
Add android:requestLegacyExternalStorage="true" in your manifest:

<manifest ... >
  <application 
    android:requestLegacyExternalStorage="true" 
  ... >
    ...
  </application>
</manifest>

Please let me know asap, I will implement it into the library after you have confirmed.
I forgot to add this.

@HBiSoft
Copy link
Owner

HBiSoft commented Jul 22, 2020

Can you please reply.

@HBiSoft
Copy link
Owner

HBiSoft commented Jul 23, 2020

I updated the readme. No response. Closing.

@HBiSoft HBiSoft closed this as completed Jul 23, 2020
@angelkoh
Copy link
Author

angelkoh commented Jul 24, 2020 via email

@HBiSoft
Copy link
Owner

HBiSoft commented Jul 24, 2020

Yes, on Android 11 it will be ignored, but you still have to keep it in your manifest for it to work on Android 10.

Google confirmed this on an issue I opened - https://issuetracker.google.com/issues/151407044

Like I said in my previous comment, file path access returned in Android 11. android:requestLegacyExternalStorage="true" is only for Android 10.

@HBiSoft HBiSoft added documentation Improvements or additions to documentation Implemented labels Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation Implemented
Projects
None yet
Development

No branches or pull requests

2 participants