Fix uncaught ApiFormatXml exception with api debuginfo

Also added tests to cover this.

Bug: 67246
Change-Id: Ifb2e392d3277a4702832727f70c77b170d4b2bf5
Merge "Fix uncaught ApiFormatXml exception with api debuginfo"