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

PermissionsAndroid request crashes #16626

Closed
srinuch1981 opened this issue Nov 1, 2017 · 5 comments
Closed

PermissionsAndroid request crashes #16626

srinuch1981 opened this issue Nov 1, 2017 · 5 comments
Labels
Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.

Comments

@srinuch1981
Copy link

srinuch1981 commented Nov 1, 2017

Is this a bug report?

Yes .
When we used PermissionsAndroid for Bluetooth permission in android we are getting crash as th

Have you read the Contributing Guidelines?

Yes

Environment

Steps to Reproduce

Android Permission in API Level (>=23) for BT using PermissionsAndroid.request API with rationale option.

  1. Accessing permission "android.permission.ACCESS_COARSE_LOCATION"
  2. Invoked from componentDidMount lifecycle method
  3. Observed crash as ArrayIndexOutOfBounds index =0

Expected Behavior

Must show Alert Dialog if not granted earlier and return grant status

Actual Behavior

Not shown Alert Dialog and Throws Exception

(Write what happened. Add screenshots!)

Reproducible Demo

N/A

componentDidMount() {
this.requestBTPermission();
}
async requestBTPermission() {
try {
const granted = await PermissionsAndroid.request("android.permission.ACCESS_COARSE_LOCATION", {
'title': 'Turn On Bluetooth',
'message': 'App needs access to your bluetooth ' + 'to connected to CEC.'
});

        if (granted === PermissionsAndroid.RESULTS.GRANTED) {
            console.log("You can use the BT now")
        } else {
            console.log("BT permission denied")
        }
    } catch (err) {
        console.warn(err)
    }
}

Logs:
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at com.facebook.react.modules.permissions.PermissionsModule$1.invoke(PermissionsModule.java:119)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at com.facebook.react.modules.permissions.PermissionsModule.onRequestPermissionsResult(PermissionsModule.java:207)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate$1.invoke(ReactActivityDelegate.java:211)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at com.facebook.react.ReactActivityDelegate.onResume(ReactActivityDelegate.java:131)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at com.facebook.react.ReactActivity.onResume(ReactActivity.java:66)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at android.app.Activity.performResume(Activity.java:6824)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3470)
07-16 10:43:40.786 10457 10457 E AndroidRuntime: ... 8 more

@HZSamir
Copy link

HZSamir commented Nov 28, 2017

+1 I am having the exact same issue

@SamMatthewsIsACommonName

this is fixed with this commit:
ce967c6
however it doesn't seem to be in the production release yet

@derakhshanfar
Copy link

@SamMatthewsIsACommonName thanks so much but how can i upgrade react-native that refer to specific commit or tag when it is not release on NPM?

@SamMatthewsIsACommonName

@derakhshanfar I've been using 0.51.0-rc.2,
I believe it's fixed in this one

@hramos hramos added the Resolution: Fixed A PR that fixes this issue has been merged. label Mar 20, 2018
@hramos hramos closed this as completed Mar 20, 2018
@LannyCodes
Copy link

@SamMatthewsIsACommonName Hi,I am having the exact same issue in 0.55.4 when I used PermissionsAndroid for Camera permission ,how do you fix this problem,please help me, Thanks!

@facebook facebook locked as resolved and limited conversation to collaborators Nov 6, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants