Adding assets to the Fennec APK file

Wed 02 July 2014 / tagged: android, build system

The Fennec Android package file includes static assets in the APK root, and in the assets directory. User jkraml recently asked how to add new assets, and we should write down how it works.

First, a word on how packaging (and re-packaging!) works. There are three phases:

Adding a file to the APK root

As an example, I’m going to take the build actions in mobile/android/base. The links below lead to a few example commits hosted on github.

First, create mobile/android/base/example.cert.


  • build: as part of the libs target, install the new file;
  • stage: add the new file to mobile/android/installer/package-manifest.in;
  • package: add the new file to $(DIST_FILES) so that it gets packed into the APK root.

Then run:

mach build-backend &&
mach build mobile/android/base &&
mach package

and you should see your new file in the root of $OBJDIR/dist/fennec-*.apk.

Adding an entire directory to the APK root

/u/anatal/">Andre Natal asked how to add a directory to the APK root. It’s a little trickier than an individual file, mostly because installing a directory into the package staging area requires care. However, you can see that the form is very similar.

Adding a file to the assets directory

This is a tiny bit trickier:

  • build: exactly the same as before;
  • stage: similar, but observe that the new file is added in a section with destdir="assets";
  • package: a new list of files packed into assets/.


It’s not hard to add files to the Fennec APK root or the assets directory. As always, you can reach me (nalexander) directly on irc.mozilla.org, channel #mobile; on the Twitters; and via the public Fennec mailing list.


  • Monday 18 August 2014: Added section and commit showing how to add a directory to the APK root.
Nick Alexander

About Nick Alexander

Mathematician. Mozillian. Runner. Master of Disguise.