Android directory naming convention caveat for PhoneGap Apps

December 15, 2014, 10:44 pm
Author: James Griffiths

Here's an interesting 'gotcha' when developing Android Apps with Cordova PhoneGap and Ionic Framework...

What's in a name?

When structuring a project for a website or mobile app build we like to collate and organise our assets in a structure akin to the following:


Depending on how far we're able to dictate the naming convention/directory structure (based on the technologies we're working with and what rules they might enforce) this approach has served us quite well.

While developing a PhoneGap App with Ionic Framework for Android we kept noticing that none of the external files (CSS, JavaScript, images and templates) would load into the App when viewed on either the Android Emulator or on an Android handset itself.

We double checked the file paths and the location of where the _assets directory and its resources were located - all was exactly as expected so what was going on? All that would display for our efforts was an unstyled template. Frustrating wasn't even close to describing how this situation felt.

No matter what we investigated nothing was amiss. If this was publishing to iOS then why the hell wasn't it working for Android??

Turns out we didn't quite check all of the output in the Ionic CLI during the android build/run process.

When we eventually did this little gem helped explain everything that we were seeing:

     [aapt] Found modified input file
     [aapt] Creating full resource package...
     [aapt]     (skipping dir '_assets' due to ANDROID_AAPT_IGNORE pattern '_*')

Oh dear.

The problem was being caused by the directory naming convention of using an underscore prefix resulting in the directory and all its resources being ignored. That's why nothing was loading/rendering in the emulator or on the Android handset - due to the build rule the directory was being ignored!

Cue a quick renaming of all directories to remove any underscore prefixes and once the App was republished to the Android handset the external CSS/JavaScript files and related assets were being parsed exactly as expected.

All that time and confusion caused by a simple underscore prefix.

Crazy huh?


« Return to Posts

Post a comment

All comments are welcome and the rules are simple - be nice and do NOT engage in trolling, spamming, abusiveness or illegal behaviour. If you fail to observe these rules you will be permanently banned from being able to comment.