Search code examples
androidhiddenassetsaapt

Packaging "hidden" asset files


I'm placing the file '.nomedia' into a folder in order to avoid Android's MediaScanner from detecting the media files in the folder. I need to copy this folder (including '.nomedia') from the APK's assets to the SD card (so other apps can make use of these media files, etc.). When I package the APK in Eclipse, it doesn't package the '.nomedia' file. Presumably it's detecting it as a hidden file. Any ideas how to fix this? Is there a secret aapt flag I can use? I'd like to avoid copying the folder and then manually creating a '.nomedia' folder, if possible.


Solution

  • I know this is several years after the question was asked, but I ran into this question searching for the same issue myself, and discovered the solution that worked for me so I thought I would post it:

    In your "ant.properties" file for your project (create a new one if you don't have it) add these two lines:

    # DO NOT ignore the .nomedia file in the assets directory!
    aapt.ignore.assets="!.svn:!.git:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
    

    This will remove the ".*" from the default exclude list, and thus .nomedia will now be included in your assets directory inside your .APK.