With Android additional files and static content are defined as resources, this includes images, layouts, strings, configuration, icons and more.
Sometimes you will need to include resources with your AIR application either to configure a service (such as Firebase) or to provide visual assets for system interactions (such as notification icons).
AIR in the past has not had a direct method for including these resources and instead you have had to build a native extension to package these resources with your application.
However, with AIR 22.214.171.1246, Harman has now introduced several options to simply include resources with your application.
The first step is always to assemble your resources into a folder. Generally we use a folder named
res to keep it inline with the Android equivalent however you should be able to use any folder name. For example:
Generally you will use tools to assemble these resources for you, such as the Android Asset Studio Notification Icon Generator
Once you have your resources, you can use one of the methods below to package these resources with your application.
Requires AIR 126.96.36.1996 or higher
The simplest method (and the method we suggest using) is specifying the resource directory in your application descriptor.
To do this, simply add the
resdir tag to your application descriptor:
Place this at the same level as the
android tag, eg:
resdir can be either the:
- relative path (as above);
- absolute path;
When using a relative path, specify the location of the folder relative to your content, eg:
We recommend using the relative path, especially if you are dealing with multiple developers where absolute paths could change between systems.
Requires AIR 188.8.131.520 or higher
If you can modify the
adt command used to build your application you can add a command line option to specify the resources directory similar to the previous method.
To do this, add the
-resdir option to your command specifying the path to your resources directory.
Unfortunately this process cannot be used by most IDEs as you cannot modify the command directly so we don't suggest using this method.
Previous to AIR 184.108.40.2060/406 you would have had to generate a custom resources native extension and add this to your application.
To this end we made a script available in the following repository to build this extension for you:
This project uses an Apache Ant build script to create and package an ANE with your custom Android resources.
Follow the guide in the repository to generate this extension.
This is still a viable solution for AIR, but we recommend the application descriptor solution for new applications.