Domanda

I have a fairly large Android project that I am trying to run Android Lint on. It works fine when I run lint with --html and produce an html file. When I run lint --xml though it produces an invalid XML file. This is problematic because I am try to integrate Android Lint into our Jenkins server and Jenkins requires the XML files. The error I am getting is:

org.xml.sax.SAXParseException; lineNumber: 144334; columnNumber: 141; 
An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" 
and element is "0".

        explanation="You can replace certain strings, such as 1/2, and 1/4, with dedicated characters for these, such as ½ (½) and 

Strangely it appears to be failing from an illegal character in the Lint explanation. I realize I could turn this particular warning off but that is less than ideal. Is there any way to prevent this from happening? Thanks!

È stato utile?

Soluzione

So it looks like I may have found a bug in the plugin. I am going to post the work around I came up with in hopes that it can help others while it is resolved. The issue that is causing this problem is that the Jenkins XML parser cannot read some of the characters in the warning explanation.

Thus when you run lint I would suggest outputting it into a file such as 'lint-report-malformed.xml' then another stackoverflow question provides a Perl script for filtering invalid characters from a file. How to remove invalid characters from an xml file using sed or Perl

perl -CSDA -pe'
   s/[^\x9\xA\xD\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]+//g;
' lint-report-malformed.xml > lint-report.xml

And now the Jenkins plugin can read the file.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top