expo: Cannot get permissions using PermissionsAndroid on standalone app
I’m trying to request READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE on freshly detached Expo app using PermissionsAndroid API. The code was almost the same as Camera permission example code except changing PermissionsAndroid.PERMISSIONS.CAMERA to PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE. However I received following error:
Error: Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity.
I tried the same code on app created by react-cli and didn’t get any error. Seems like Expo SDK activity doesn’t extend ReactActivity nor PermissionAwareActivity. Is there any other method to manually request these permissions?
Additional info: “expo”: “^21.0.0”, “react”: “16.0.0-alpha.12”, “react-native”: “https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz”,
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (3 by maintainers)
For those who need it, here is my edit to
MainActivity.javato get things to work. There may be a better way to write this. I don’t know Java very well.Hey all,
In an effort to clean up and gain more clarity over our issues, we’re closing old issues that may no longer apply to our currently supported versions. If you are able to still repro this, please open a new issue with a repro case and we’ll be happy to investigate.
Cheers,
Adam
I am unable to use in expo version 29. Same issue. @AmolGslab Did you find Solution?
@TimothyKrell Getting same error “Tried to use permissions API but the host Activity doesn’t implement PermissionAwareActivity.” after updating MainActivity.java as provided by you. Expo V : 55 Android SDK 26
Thanks.
@tedkimzikto Agreed, I think it should be considered a bug for an ejected project with expokit to not have this already implemented in the MainActivity.
I too borrowed some parts from
ReactActivityto fix this for my project, but it’s a shame, this is such a basic functionality compared to other complex things expokit already give us 🙂 .This is still a problem with Expo SDK v31.0. @TimothyKrell thank you - your solution worked.
@mateusmedeiros I’ve managed to implement PemissionAwareActivity from MainActivity under android project. Refer to ReactActivity.java from RN (https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java)
I’m not sure why detached project is not handling these issues 😦
Chiming in just to say that I’m also having this problem with those exact same versions of everything, also right after ejecting a pure expo app and running on an Android 7.1.
@ide Tested on Lenovo Moto M Android 6.0