title: Bitmap.compress() is not working on Android Oreo
body: <p>I have a small bit of code in my app that has been there for more than 2 years, working just fine. We just discovered that it is <em>not</em> working on <code>Oreo</code> devices. Here's the code:</p>
  
  <pre><code>    Bitmap bm = getAsBitmap(200, 100, 5);
      if (bm != null) {
          ByteArrayOutputStream stream = new ByteArrayOutputStream();
          bm.compress(Bitmap.CompressFormat.PNG, 50, stream);
          return new String(Base64.encode(stream.toByteArray(), Base64.DEFAULT));
      }
  </code></pre>
  
  <p>In all versions of Android prior to <code>Oreo</code>(or at least API Level 14-25) this code produces a base64-encoded string serialization of the bitmap. In <strong><code>Oreo</code></strong> it produces an empty string.</p>
  
  <p>Stepping through it with the debugger, it is clear that the problem is with <code>bm.compress()</code> – after running this the stream is still empty. If I debug this same code on my <code>Nougat</code> device I can see the stream contains PNG data.</p>
  
  <p>Our build runs <code>compileSdk 25</code>, but just to be sure I updated our build to <code>compileSdk 26</code> and updated the build tools and support libraries to 26 as well; there was no change in behavior.</p>