how to reference an asset in a library project

This answer is out of date, the gradle build system and AAR files support assets.


From the Android Docs:

Library projects cannot include raw assets

The tools do not support the use of raw asset files (saved in the assets/ directory) in a library project. Any asset resources used by an application must be stored in the assets/ directory of the application project itself. However, resource files saved in the res/ directory are supported.

If you want to include files from a Library project, you’ll need to put it in the resources instead of the assets. If you’re trying to load HTML files from your library project into a WebView, this means that you’ll have to go a more roundabout method than the usual asset URL. Instead you’ll have to read the resource data and use something like loadData.

Leave a Comment