Skip to content

Requesting permission results into java.lang.ArrayIndexOutOfBoundsException #15928

@msidlo

Description

@msidlo

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

  1. react-native -v: 0.45.1
  2. node -v: 7.9.0
  3. npm -v: 4.2.0
  4. yarn --version: 0.23.2

Then, specify:

  • Target Platform: Android
  • Development Operating System: macOC Sierra
  • Build tools: Android Studio

Steps to Reproduce

  1. ask for permission just like in documentation
  2. press home button
  3. open the App again and it crashes on this line
    if (results[0] == PackageManager.PERMISSION_GRANTED) {

Expected Behavior

Check results array before accessing it.
instead of
if (results[0] == PackageManager.PERMISSION_GRANTED) {
something like
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {

Actual Behavior

On some devices app crashes after Requesting a permission on Android. App crashed on Xiaomi Redmi 4 Prime(Android 6.0.1), Lenovo C2 (Android 6.0), Sony Xperia Z3Compact (Android 6.0.1), Samsung Galaxy A3 (Android 7.0.). App is not crashing on Huawei P10 lite(Android 7) or Sony Xperia L1(Android 7). After crash, the app is restarted.

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions