Skip to content

Instantly share code, notes, and snippets.

@creativedrewy
Last active September 12, 2016 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativedrewy/da55ae92d3516460884fbe4e9d1b900a to your computer and use it in GitHub Desktop.
Save creativedrewy/da55ae92d3516460884fbe4e9d1b900a to your computer and use it in GitHub Desktop.
## Quick Hit: Android menus inside library projects

Summary: Android has issues if you have identically named menu resources in a library and consuming app project.

I recently discovered something to look out for if you are attempting to work with Activity toolbar/actionbar menus inside of a library. In my case, here is what I was doing:

  • Working with an activity inside of a library project.
  • Attempting to inflate a menu resource in the library Activity that was contained inside of the library project.
  • Open the library activity (actually an extended version of the activity) from the consuming Android app.

When I ran my consuming app activity, I was not seeing changes reflected to the menu in my app. This was really, really confusing.

It turns out that the problem was I had a menu resource xml in my consuming app with the exact same name as the library project menu. Even though the menu was referenced in the library activity with the library package resource, the consumnig app ended up picking its identically named version.

Changing the name of my library menu xml file fixed the issue right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment