title: API 26+: WRITE_EXTERNAL_STORAGE permission is always denied
body: <p>I have switched my app to target API 27 and now it can't be granted <code>WRITE_EXTERNAL_STORAGE</code> permission -- <code>grantResult</code> is always <code>-1</code>.</p>
  
  <p>My app needs this permission since it doesn't use apps private external storage space (which <a href="https://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE" rel="noreferrer">doesn't require</a> <code>WRITE_EXTERNAL_STORAGE</code> starting from API 19).</p>
  
  <p>I know that in API 26 there have been <a href="https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp" rel="noreferrer">behavior changes for permissions</a>. However this doesn't explain my problem.</p>
  
  <p>I'm requesting both <code>READ_EXTERNAL_STORAGE</code> and <code>WRITE_EXTERNAL_STORAGE</code> permissions in a standard way:</p>
  
  <pre><code>ActivityCompat.requestPermissions(activity, new String[] {
          Manifest.permission.READ_EXTERNAL_STORAGE,
          Manifest.permission.WRITE_EXTERNAL_STORAGE
      }, requestCode);
  </code></pre>
  
  <p>(both permissions are declared via <code>&lt;uses-permission</code> in manifest).</p>
  
  <p>The dialog appears and I click "Allow":</p>
  
  <p><a href="https://i.stack.imgur.com/bTKft.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bTKft.png" alt="enter image description here"></a></p>
  
  <p>However inside <code>onRequestPermissionsResult</code> callback I'm getting a <code>-1</code>(denied) for <code>WRITE_EXTERNAL_STORAGE</code> (and <code>0</code> (granted) for <code>READ_EXTERNAL_STORAGE</code>).</p>
  
  <p>Shouldn't the result be <code>0</code> for both since I have requested and, presumably, granted both?</p>
  
  <p>I have tried to request <code>WRITE_EXTERNAL_STORAGE</code> alone, but in this case the dialog doesn't appear at all.</p>
  
  <p>One more detail: I have just checked the merged manifest in <code>build/intermediates/manifests/full/debug</code> and noticed that <code>WRITE_EXTERNAL_STORAGE</code> permission has attribute <code>android:maxSdkVersion="18"</code> (there is no such attribute in my manifest). This could be happening because my app has <code>minApiVersion=21</code>, but I'm not sure.</p>