Strange ArrayIndexOutOfBoundsException in android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback : <p>I received a strange out of bounds exception in the Play Store console relating to the <a href="https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback.html" rel="noreferrer">android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback</a></p>

<pre><code>java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
    at com.example.MyFragmentActivity.onRequestPermissionsResult(MyFragmentActivity.java:2068)
    at android.app.Activity.requestPermissions(Activity.java:4163)
    at android.support.v4.app.ActivityCompatApi23.requestPermissions(ActivityCompat23.java:32)
    at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:316)
    at com.example.MyFragmentActivity.onConnected(MyFragmentActivity.java:2048)
    at com.google.android.gms.common.internal.zzk.zzk(Unknown Source)
    at com.google.android.gms.common.api.internal.zzj.zzi(Unknown Source)
    at com.google.android.gms.common.api.internal.zzh.zzpx(Unknown Source)
    at com.google.android.gms.common.api.internal.zzh.onConnected(Unknown Source)
    at com.google.android.gms.common.api.internal.zzl.onConnected(Unknown Source)
    at com.google.android.gms.common.api.internal.zzc.onConnected(Unknown Source)
    at com.google.android.gms.common.internal.zzj$zzg.zzqL(Unknown Source)
    at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
    at com.google.android.gms.common.internal.zzj$zza.zzw(Unknown Source)
    at com.google.android.gms.common.internal.zzj$zzc.zzqN(Unknown Source)
    at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
</code></pre>

<p>This is my onRequestPermissionsResult implementation</p>

<pre><code>@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    switch (requestCode) {
        case REQUEST_CODE_ASK_LOCATION_PERMISSIONS:
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // Permission Granted
                if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
                    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
                }
                startLocationUpdates();
            } else {
                // Permission Denied
            }
            break;
        default:
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}
</code></pre>

<p>Line 2068 is this:</p>

<pre><code>if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
</code></pre>

<p>I believe it's claiming <code>grantResults</code> length is zero which is why the java.lang.ArrayIndexOutOfBoundsException is thrown.  According to the <a href="https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback.html" rel="noreferrer">documentation</a> </p>

<blockquote>
  <p>int: The grant results for the corresponding permissions which is
  either <strong>PERMISSION_GRANTED or PERMISSION_DENIED. Never null.</strong></p>
</blockquote>

<p><code>grantResults</code> will not be null, but doesn't say anything about it not containing a value either.  Furthermore it seems like the callback will contain at least one value, either <code>PERMISSION_GRANTED</code> or <code>PERMISSION_DENIED</code>.  Is this a bug or am I misunderstanding the documentation?</p>
