Saturday, January 26, 2019

Could not send ACRA Post responseCode=402 message=Payment Required

So most likely you are using ACRA with Cloudant as a back-end. Your LITE account has reached the limit of 1 GB of data. Purging old crash reports should help.

Your Cloudant Dashboard is available at:

Wednesday, October 31, 2018

Scarborough Fair for diatonic harmonica

Here is another easy one. Scarborough Fair for diatonic harmonica, beginner level. Both tabs and sheet music. Enjoy it!

Downloadable PDF:
Scarborough Fair - diatonic harmonica.pdf

Thursday, October 25, 2018

Clair De Lune for diatonic harmonica

I was having fun with Yousician, playing their arrangement of Clair De Lune for a guitar - and I said why not play it on a diatonic harmonica! I wrote down the notes from their arrangement, transposed everything one octave up (in order to avoid bending) and - voila!

Clair De Lune for diatonic harmonica, beginner level. Both tabs and sheet music. Enjoy it!

Downloadable PDF:
Clair De Lune - diatonic harmonica.pdf

Wednesday, October 29, 2014

org.w3c.dom.DOMException: Motörhead at org.apache.harmony.xml.dom.NodeImpl.setNameNS(

As an example, let's take a look at the simple XML file (test.xml):
<?xml version="1.0" encoding="UTF-8" ?>
 <Motörhead>Ace of Spades</Motörhead>
If you are confused by the tag name that contains special character, rest assured that is perfectly valid, accents and diacritics are acceptable, see here.

Let's take the following Java snippet and run it with 1.6 or 1.7 compiler:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
File file = new File(INPUT_FOLDER + "test.xml");
Document document = db.parse(file);
Everything runs fine, as it should. However, if we run the same code on Android (any version), we'll get the following:

org.w3c.dom.DOMException: Motörhead
at org.apache.harmony.xml.dom.NodeImpl.setNameNS(
at org.apache.harmony.xml.dom.ElementImpl.(
at javax.xml.parsers.DocumentBuilder.parse(

Ah, that little green robot ... always full of surprises. Let us not be lazy and see what is really happening in Android's NodeImpl.setNameNS() method:

(240)  if (!DocumentImpl.isXMLIdentifier(qualifiedName)) {
(241)      throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 
(242)  }
Ok, let's take a look at DocumentImpl.isXMLIdentifier()
(92)   private static boolean isXMLIdentifierStart(char c) {
(93)       return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') 
               || (c == '_');
(94)   }
(96)   private static boolean isXMLIdentifierPart(char c) {
(97)       return isXMLIdentifierStart(c) || (c >= '0' && c <= '9') 
               || (c == '-') || (c == '.');
(98)   }
(100)  static boolean isXMLIdentifier(String s) {
(101)      if (s.length() == 0) {
(102)          return false;
(103)      }
(105)      if (!isXMLIdentifierStart(s.charAt(0))) {
(106)          return false;
(107)      }
(109)      for (int i = 1; i < s.length(); i++) {
(110)          if (!isXMLIdentifierPart(s.charAt(i))) {
(111)              return false;
(112)          }
(113)      }
(115)      return true;
(116)  }
Faulty implementation. Which is not surprise since Android's org.apache.harmony.xml has a lot of issues open. I submitted this one here.

Now I am sure that you, just like me, can not wait for Android engineers to fix the problem, besides the faulty library is already present on millions of Android devices right now and your app has to run on those devices too. So workaround would be not to use Android's library at all, but to replace it with something reliable. I have solved my problems using Xerces for Android that I have found here.

Case closed!