title: BitmapFactory.decodeStream from Assets returns null on Android 7
body: <p>How to decode bitmaps from Asset directory in Android 7?</p>
  
  <p>My App is running well on Android versions up to Marshmallow. With Android 7 it fails to load images from the Asset directory.</p>
  
  <p>My Code:</p>
  
  <pre><code>private Bitmap getImage(String imagename) {
      // Log.dd(logger, "AsyncImageLoader: " + ORDNER_IMAGES + imagename);
  
      AssetManager asset = context.getAssets();
      InputStream is = null;
      try {
          is = asset.open(ORDNER_IMAGES + imagename);
      } catch (IOException e) {
          // Log.de(logger, "image konnte nicht gelesen werden: " + ORDNER_IMAGES + imagename);
          return null;
      }
  
  
      // First decode with inJustDecodeBounds=true to check dimensions
      final BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      BitmapFactory.decodeStream(is, null, options);
  
      // Calculate inSampleSize
      options.inSampleSize = calculateInSampleSize(options, PW, PH);
  
      // Decode bitmap with inSampleSize set
      options.inJustDecodeBounds = false;
  
      // Lesen des Bitmaps in der optimierten Groesse
      return BitmapFactory.decodeStream(is, null, options);
  
  }
  </code></pre>
  
  <p>As a result (only Android 7) <code>BitmapFactory.decodeStream</code> is null. It works correctly an older Android APIs.</p>
  
  <p>In debug mode I see the following Message:</p>
  
  <blockquote>
    <p>09-04 10:10:50.384 6274-6610/myapp D/skia: --- SkAndroidCodec::NewFromStream returned null</p>
  </blockquote>
  
  <p>Can someone tell me the reason and how to correct the coding?</p>
  
  <p>Edit: Meanwhile i found, that removing of the first BitmapFactory.decodeStream with inJustDecodeBounds=true leads to a successful BitmapFactory.decodeStream afterwards with inJustDecodeBounds=false. Don't know the reason and don't know how to substitute the measurement of bitmap size.</p>