-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Permissions Broken For Android 29 (Q) on any openPicker/openCamera calls due to Environment API Deprecations #1110
Comments
Can anybody give guidance on how to get the project set up for android development? If I just open the .iml I get issues with the library plugin not being found, and if I explicitly put in a gradle dependency it fails to find the react-native library. I'm definitely down to try and fix this for the community, I'm just struggling to get up to speed |
Android SDK 29 deprecated the following method for getting external directories that we use repeatedly. https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String) I converted the various use cases to use the suggested alternative in the Context API. https://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)
Android SDK 29 deprecated the following method for getting external directories that we use repeatedly. https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String) I converted the various use cases to use the suggested alternative in the Context API. https://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)
Android SDK 29 deprecated the following method for getting external directories that we use repeatedly. https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String) I converted the various use cases to use the suggested alternative in the Context API. https://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)
um, the documentation says:
and your versions are:
I'm not sure whether this is the reason but who knows. |
I've Jetified react native 59.10 for compatibility between the two. Everything works without a hitch using targetSdkVersion 28, but as soon as that is flipped to targetSdkVersion 29 the filesystem calls fail with perm problems due to how Android deprecated their Environment apis in a breaking way. At this point in React Native 61 the targetSdkVersion is still set to 28 so almost all users will not be affected yet, but this library is essentially a time bomb for the day that react native finally upgrades |
Possibly related (fixed permissions issues for me):
Per the second link:
Workaround: I believe the real solution would be to change the location where files are being stored to use |
Thanks for the workaround! Worked like a charm! |
This is the section of code that needs to be changed: Lines 786 to 793 in b517626
|
* Switch Android SDK 29 deprecated methods to alternatives (#1110) Android SDK 29 deprecated the following method for getting external directories that we use repeatedly. https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String) I converted the various use cases to use the suggested alternative in the Context API. https://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String) * Updated podspec * Added iOS 13 DarkMode for picker (#1129) * Update README.md * version bump * Removed isMovingToParentViewController so scroll to bottom works (#1137) * Fix deprecated RCTImageLoader.h import (#1142) * upgrade example project to react-native 0.61 * version bump * Update README.md * Fix crash after video recording in ios13 & xcode11 (#1145) * Fix crash after video recording in ios13 & xcode11 UI-related code should run in main thread, as exception says: `Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread'` * Typo fix * Fix xCode warnings about main thread execution (#1146) This kind of warnings also presents in output console if Main Thread Checker is active * ignore iml files * version bump * Fix typo (#1150) Changed the word "noticable" to "noticeable". * update type (#1200) * CocoaPods - Properly Interpolate Tag Version (#1174) Why? * Ruby uses `"` quotes when interpolation is required. Using `'` will mean `v#{version}` is used directly rather than providing the version number. Changes: 1. User Ruby string interpolation when setting the tag version for the source. * small typing improvements * version bump * fix typings for writeTempFile * version bump * (ios) changing images sort order * upgrade react-native-cli * using local QBImagePicker as podspec * Update README.md (#1265) Clarify that avoidEmptySpaceAroundImage option is (ios only) * testing with sdk 29 * update yarn.lock * version bump Co-authored-by: Phil Simmons <phil@flyclops.com> Co-authored-by: Yury Korzun <yury@flyclops.com> Co-authored-by: cr1s3c <yannre1210@gmail.com> Co-authored-by: Filipe Merker <filipesmerker@gmail.com> Co-authored-by: Artur Eshenbrener <strate@yandex.ru> Co-authored-by: Suraneti Rodsuwan <suraneti.rod@gmail.com> Co-authored-by: mikunimaru <43168745+mikunimaru@users.noreply.github.com> Co-authored-by: Peter Lucak <login@peterlucak.com> Co-authored-by: Ivan Pusic <ivpusic@users.noreply.github.com> Co-authored-by: Mujtaba F. Radhi <al.mujtaba@hotmail.com>
Version
Platform
Expected behaviour
On a device running Android SDK 29 a call to
ImagePicker.openCamera
/ImagePicker.openPicker
should prompt for permissions and then on acceptance open the picker or cameraActual behaviour
Even when the user grants permissions the picker or camera will eventually fail once an attempt is made to get a storage directory
Steps to reproduce
Have Phone Running Android SDK 29
Use
openCamera
oropenPicker
and grant required permissionsopenCamera fails immediately and openPicker fails at cropping phase
Attachments
For openCamera the following error appears with no stack trace:
E/image-crop-picker: Promise rejected. Permission denied
For openPicker there is a full stack trace
I discovered the general Android 29 behavior here
https://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android`
which led to a solution suggestion here
https://stackoverflow.com/questions/56468539/getexternalstoragepublicdirectory-deprecated-in-android-q
More info in deprecation here https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String)
I am very willing to work on adding support, I'm reaching out mostly for guidance on the process for doing so.
Love react-native-image-crop-picker? Please consider supporting our collective:
👉 https://opencollective.com/react-native-image-crop-picker/donate
The text was updated successfully, but these errors were encountered: