Skip to content

PermissionsAndroid request crashes  #16626

Closed
@srinuch1981

Description

@srinuch1981

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: FixedA PR that fixes this issue has been merged.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions