Wednesday, March 31, 2010

Dweller is running on Blackberry devices!

Previous versions of Dweller have unfortunately not run on all Blackberry devices. The game used to crash on most models. The cause of the crash was actually a rather interesting one. In older versions of Dweller all game data (monsters, items etc) were compiled into the code through a single auto generated static class. The class was generated by a parser tool that parsed an XML file containing all the game data. Due to the size of this class and all the static data it for some reason caused a crash and the rather cryptic "invalid constant pool index: 0 in " error message.

So, why didn't I use the XML file straight up and parsed it runtime instead of doing this complicated XML to static class thing? I did it for two reasons: 1) File size. The XML file would take up much more space than a compiled (and obfuscated) class file. 2) XML parsing on J2ME handsets is no piece of cake. There are XML parsers out there, kxml for instance, but they aren't very easy to work with.

My solution to the problem was to convert the XML to class parser into an XML to binary data parser. The parser spits out a couple of streamlined binary files, ready to be read back at runtime by the game. And that did the trick! Blackberry users around the world, rejoice, play and have fun!


  1. Sad day for this Blackberry Bold 9700 user. I downloaded the 0.14.0 (that's what the version on the download screen says when it is installed) and installed it but when I attempt to run it I get the error:
    Uncaught exception:
    There is no previous version installed, I have given it trusted access and marked all access as Allowed and also have done a battery pull reset on the blackberry, all to no avail =( Keep up the great work and I can't wait to one day try it out!

  2. Nathan, I'm sorry for not responding sooner, your comment slipped under my radar. I was hoping for the new version to work well on Blackberry handsets... grr... Do you get any additional information besides the NullPointer? I will try and add some extra error handling mechanisms for the next release to try and catch what goes wrong.