0

I am trying to use apktool/aapt/aapt2 to rebuild an APK but I encountered an error when using the tools. The message states "error: not well-formed (invalid token)". This is because of the use of unicode characters in the various xml files for the class names etc.

Is there anyway I can convert those unicode names to an ASCII equivalent? I have tried to escape the characters in the XML files using

  • &#x....
  • &#.... (decimal equivalent of &#x)
  • \u....
  • \xxxx

However, none of the above escaping works. Any advice is greatly appreciated.

localacct
  • 611
  • 5
  • 13
  • 1
    Possible duplicate of [Android XML Percent Symbol](https://stackoverflow.com/questions/4414389/android-xml-percent-symbol) – Izabela Orlowska Sep 19 '18 at 11:01
  • Thanks Izabela for your reply. I looked at that other post but I am not sure if its related to my problem. That post was about format specifiers but my question is about the presence of unicode characters causing some problems with apktool/aapt/aapt2. If I am wrong in anyway, please do provide some guidance. Thanks for the help – localacct Sep 21 '18 at 01:17
  • Hmm okay, can you give an example of a name/value that isn't working for you? – Izabela Orlowska Sep 21 '18 at 15:08
  • Hi Izabela, for example one of the xml files in (/res/layout) has such a configuration ( You can see the second character is a unicode character and that is the one that caused the error in parsing the xml file for apktool/aapt/aapt2 – localacct Sep 24 '18 at 02:51
  • Ah okay, I haven't encountered anything like this in the past. I'd suggest just sticking to ASCII characters and refactoring existing code to adhere to that. AFAICT AAPT/AAPT2 uses UTF-8 encoding, so it's possible that's why you're getting that error. Also could this be of use https://blogs.msdn.microsoft.com/gongcheng/2010/03/30/how-to-encode-non-ascii-characters-in-xml/? – Izabela Orlowska Sep 24 '18 at 16:15
  • Thanks Izabela. I tried the encoding mentioned in the links but it has not helped. Guess I have to continue looking for solutions. – localacct Sep 25 '18 at 07:31

0 Answers0