Wednesday, 28 October 2020

Android published library xml attributes not found (AAPT)

** See edit below **

I built a multi-library project and published it to a private repository on jitpack.io successfully. Some of the libraries contain resources in the form of layout files, etc. I have another project that implements these libraries and builds fine, but when I try to run it, I keep getting an error regarding attributes in some of the layout and navigation files (from the libraries):

For instance, I'm loading a layout file called fragment_radio_main that is imported from com.github.username.libraryname:radio:version. In that layout, I have a RecyclerView which uses the attribute app:layoutManager. This is where the failure is happening

AAPT: error: attribute layoutManager (aka com.organization.appname:layoutManager) not found.
AAPT: error: attribute sc_border_width (aka com.organization.appname:sc_border_width) not found.
AAPT: error: attribute sc_corner_radius (aka com.organization.appname:sc_corner_radius) not found.
AAPT: error: attribute sc_tint_color (aka com.organization.appname:sc_tint_color) not found.
AAPT: error: attribute defaultNavHost (aka com.organization.appname:defaultNavHost) not found.

In the above logs, layoutManager was from RecyclerView, the attributes with the prefix sc_* are from a 3rd party library that one of my layouts uses, and defaultNavHost is from NavHostFragment from the Navigation library. There are many more attributes that are failing, but I believe this gets the point across.

In the aka line(aka com.organization.appname:sc_tint_color), the attribute sc_tint_color is not actually an attribute defined by com.organization.appname, but rather, defined by a 3rd party. Maybe there's some configuration that needs to happen to resolve these attributes? I'm just stuck on this.

If you need further info, I'd be glad to provide. Any help would be greatly appreciated.

** EDIT 11/27/2019 **

It turns out that, if I import my Radio library to my current project, I also have to add any 3rd party dependencies my Radio library used that contain resource (specifically, in this case, styleable) files in my current project to gain access to those attributes.

So I guess my question is, does anyone know how to avoid having to do this?



from Android published library xml attributes not found (AAPT)

No comments:

Post a Comment