Adding assets to the Fennec APK file
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:
- build: the build installs files into $(FINAL_TARGET), which is usually $OBJDIR/dist/bin;
- stage: the Python packager runs and moves files from $(FINAL_TARGET) into the staging area, which is usually $OBJDIR/dist/fennec;
- package: the packaging scripts zip (part of) the staging area into the APK.
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.
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:
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.