5

Based on Android Library Considerations:

Library modules cannot include raw assets

I created a sample android library module with assets in there (not in app module), then generated the aar file. I analyzed the resulting aar file, and voila, the assets/ folder is still there with all the files intact.

So, is it allowed or not allowed?

user1506104
  • 6,554
  • 4
  • 71
  • 89

4 Answers4

4

I think that some of the Development considerations are outdated. For example they also says that <uses-library> elements must be declared in both the library and the application (this is now handled by the manifest merger).

By the way a few lines below, Anatomy of an AAR file shows that an AAR file may include an /assets/ directory

bwt
  • 17,292
  • 1
  • 42
  • 60
4

I raised this document problem in Android Library Considerations: with Google on May 7, 2018 issuetracker 79311037.

It is being dealt with, here's the latest comment (Jul 14, 2018):

As well as being wrong, the documentation also contradicts itself, as the "Anatomy of an AAR file" section at the bottom does include an assets directory.

Jon Goodwin
  • 9,053
  • 5
  • 35
  • 54
3

Folder assets/ is not allowed in android library. you can access it from res/raw with following code.

context.getResources().openRawResource(R.raw.file_name);
Brijesh Gupta
  • 487
  • 4
  • 8
2

Here are some interesting posts on the subject:

how to reference an asset in a library project

Android Library assets folder doesn't get copied

All it says is that: Library modules cannot include raw assets it does not say Library modules should not include raw assets . Maybe in the past it was not supported. Now as the above posts and their answers indicate it is supported.

nkhar
  • 225
  • 1
  • 4
  • 13