• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Android loading a packaged asset fails due to compression

Engaged ,
Jun 10, 2014 Jun 10, 2014

Copy link to clipboard

Copied

Hi,

I've been trying to create a way to play a media file that is packaged with an AIR application from within a native extension. However I've come into a problem that seems to be related to the way the assets are getting packaged into the APK. I'm trying to access the files using the Android AssetManager something like:

     context.getAssets().openFd( "video/big_buck_bunny.mp4" );

However this commonly results in the error:

     java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

I can list out all the assets in the AssetManager and can definitely confirm the asset is known and present. When I inspect the packaged APK, indeed the file is compressed and not Stored as it should be. eg the following is a file from unzip -v App.apk

5510872  Defl:N  5044897   9%  06-11-14 12:15  30431fa9  assets/video/big_buck_bunny.mp4

where you can see the Defl:N indicates it's compressed (by 9%). However some files will be Stored correctly:

  390668  Stored   390668   0%  11-15-13 10:06  2d380eae  assets/Default-568h@2x.png

    5015  Defl:N     4384  13%  03-25-13 21:24  2b6284ce  assets/Default.png

  211743  Defl:N   211329   0%  11-12-13 10:58  9384a8ae  assets/icons/icon512x512.png

    6536  Stored     6536   0%  11-12-13 10:58  ea5ca1e6  assets/icons/icon57x57.png

It seems very inconsistent with an AIR application. According to the documentation Android should not compress the following asset file types (from Package.cpp in the aapt source code):

".jpg", ".jpeg", ".png", ".gif", ".wav", ".mp2", ".mp3", ".ogg", ".aac", ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".amr", ".awb", ".wma", ".wmv"

and indeed when I package the same assets in an android packaged application the files aren't compressed.

Of course I know I can work around this by reading the file out and writing it to a cache or temp location however this seems to be a bug in the way AIR is packaging Android applications and was wondering if anyone has encountered this or found a workaround.

Cheers,

Michael

air native extensions // https://airnativeextensions.com
TOPICS
Development

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines