AppStream Error in Ubuntu 16.04 Xenial

I’d been seeing this error recently:

AppStream cache update completed, but some metadata was ignored due to errors.

According to a Q&A on AskUbuntu, this is the result of a bug in the app stream package.

The package has as of 24 December is not yet in the package updates for 16.04; therefore, to fix it one either needs to add it from the proposed repository or from the backports repository.

Once you’ve enabled the backports repository (which you may not have to do at all) you can specifically pull the package from backports with this command:

sudo apt install appstream/xenial-backports

Now instead of the default version 0.9.4, you should have the updated version (0.10.1 of this writing):

appstreamcli —version
AppStream CLI tool version: 0.10.1

To complete the process, you need to update the cache data:

sudo appstreamcli refresh —force

Then make sure to do an update and upgrade to get any missed updates:

sudo apt-get update
sudo apt-get upgrade

And clean up the last of the update by removing the now unneeded libappstream3:

sudo apt-get autoremove

This should fix the problem once and for all.