On Android Fragmentation

As an Android developer I get asked a lot about fragmentation on Android and if it’s doable in dealing with it. Judging from the attention it gets in the media, the question is understandable. There is supposedly a lot to do about Android fragmentation. Every once in a while stories about the subject dominate the news. But as an software developer and every day Android developer the question always surprises me a bit.

Nothing new here

Before I was into Android development, I build websites and web-applications. And I don’t recall people asking me about how to deal with all the screen sizes and all the different browser versions. There was IE6 of course, but somehow everybody had some sort of understanding that IE6 was the only exception.

Similar is the situation when developing applications for the desktop. Different versions of the OS, different screen sizes, different hardware. Nobody seems to wonder how the developers of MS Office have to cope with it all. I my opinion fragmentation is nothing new. It’s more unique that you do not have to worry about it (like on iOS in a way).

So how does fragmentation manifest itself on Android and is it really a that bad?

Screen sizes

This is the obvious one. It might look like a big problem, but I think it actually isn’t. First of all because Android gives you a lot of tools to deal with different screen sizes. Think of the densities (LDPI, MDPI, HDPI, etc..) and the layouts you can override .

Second when you specify all your dimensions in dp’s (density independent pixels) you will discover that most screens have roughly the same aspect ratio. Now you just test the on the smallest screen you want to support (say HTC Wildfire) and on the biggest screen you want to support (Samsung Galaxy S III). If it looks good on both you’re done, if not tweak a bit (mostly for the small screen).

What about tablets? Most clients I worked with in Europe are not yet paying for a tablet layout, but if you have to build a hybrid application, than the layout variants are your friend. There are a lot of guides on the http://developer.android.com that explain to you how you can build an application that adapts to the users available screen size .

Different versions of Android (API levels)

This is also a problem on iOS, but on Android it’s bigger because vendors update slowly or not at all to new versions of Android. Therefore there are more different versions of Android available in the wild than versions of iOS.

In my opinion this is the biggest problem with Android fragmentation. In practice I’m still writing apps for Android 2.2 and judging from the market share it is going to take a while before we can leave Android 2.X behind. 2.3.X has a whopping 54% market share. This means it is gonna take at least 3 more years before we can even think about developing for Android 4.X only. This is sad as the Android 4 SDK brings a lot of good new stuff, but the best stuff is backported by the support library or efforts like Actionbar Sherlock . So it is manageable.

Vendor specific bugs

This is a real problem but fortunately also very rare in my experience. I have encountered this problem only once. It was an old HTC phone running Android 2.2 and it didn’t want to parse a date while the date format was exactly as specified.

The team had a really though time finding the bug, but that was because the exception got consumed by a catch clause (which wasn’t intended to catch it). Working around such bugs has been easy but detecting them can be a pain if disregard best practices. In other words never write catch (Exception e) {}, it is evil.

Conclusion

This has become a pretty long post. This may lead you to believe that fragmentation is a big problem, as it seems you have to account for a lot of things. I am certainly not saying that the fragmentation does not exist and you certainly have deal with it. But that said, when you stick to the best practices and build your app “the right way™” I find it doesn’t take a lot of extra effort take make your app run on all the devices and scale across all the screen sizes.

Virtualizing My Development Environment

Last week I have been busy moving my development environment from my laptop to a virtual server running on my laptop. This my seem like a hassle and the advantages are not all obvious, so I would like to share my findings and the specifics of my setup that I settled on.

Security / Privacy

First I would like to point out the problems I had with my current setup.The most urgent concern I had was that if my laptop would get stolen all my projects would be out in the open. I use the laptop primarily for my company projects and thus contains at lot of information from my clients. Think about copies of a database with maybe lots of user account information. It would be bad if my company would be responsible for the leaking of private information of other company’s. It is clear that I needed a way to protect my information (probably encryption), but I didn’t want it to get to much in my way.

It should just work

My primary OS is Archlinux. As a desktop OS it suits my needs just fine. I like to tweak things and it runs very fast. On the other hand I am very used to Ubuntu and typically setting up a LAMP environment is less work on Ubuntu that it is on Archlinux. It also matches better with the servers we deploy on and the other developers are also Ubuntu users.

Most important my development environment should just work ALWAYS! I’ve had some occasions that I reinstalled my system and forgot to install some tools only to discover at an appointment with a client. Not good… Isolating the development environment from my host OS enables me to chose a different environment and also allows me to preserve it during reinstalls of the host OS.

The setup

Enough blabla, on with the details. For virtualization I used Virtualbox. I haven’t used anything else and directly admit I use it for its simplicity. As a guest OS I use Ubuntu Server. I installed it with encrypted LVM. This way all data inside the virtual server is encrypted (and thus sort of safe). This safes me from all the trouble of keeping track where my database is stored and where my documentroot is from the webserver and if they are exposed or not.

Networking

So far all has been nice. But I can’t use my virtual server without access to it. There are a number of options to try and I will discuss 2 possible setups.

First I went for bridged networking. This way the virtual server will appear in the same network as the host. This is quite flexible and only has two problems. The first being that it is not always good to have your virtual server accessible for the hole network (for instance when connecting directly to the internet or hotel wireless). Second is more of a bug and that is that it just not always works on all networks. Some routers just don’t seem to get it when two operating systems request an ip from one physical network card.

To solve the to issues a made a second setup. This time I configure two network cards on the virtual server. One uses NAT and is primarily for internet access. The second uses host-only networking and is used by myself for accessing the virtual server. This has some advantages. First being that it works on buggy routers and second, it makes the network layout much more predictable as you have your own internal network address space. This allows you to hard code the network addresses in scripts. The only disadvantage of this setup is that other computers can’t access the server.

At the moment I use the second solution. Maybe I will switch the NAT to bridged networking when the routers allow it, but I’m not sure if I will need it. The host only network is great and saves me the trouble of looking up the ip from my server every time. I can now use a script to mount the document root using NFS.

Hope this was useful comments are welcome.

cheers.

Current Projects

It’s about time I started blogging about my game projects. As part of a research semester for my study I’m building some prototype games to explore game development in Python. Our first one, Pyrio, is already done and turned out to be quite nice. The second, tank-battle, is lagging a bit behind our own expectations but is nevertheless quite nice, though I don’t plan to do all the packaging stuff for this one.

Pyrio is a Mario clone. It uses graphics and sounds from Secret Maryo Chronicals and is written with Pygame. One of our findings was that rendering with Pygame was much to slow so for Tank-battle we started using Cocos2d / Pyglet. Tank-battle is not really a game but more a tech-demo. It plays with networking and AI. The networking part is built on top of Twisted and works quite well. We even built some interpolation code on the client which makes prevents opponents from jittering around the screen. We are now in the process of building some path finding into some computer players and make them do smart things. But time is almost up as tomorrow will be the last day of development and we ain’t got anything battle related, so it’s just tanks for now ;-)

In the upcoming weeks we will build a 3D prototype, participate in the Pyweek and further develop our Pyweek game afterwards. In the meantime, try Pyrio ;-)

Blog Moved to New Host

When you read this my blog is moved to my new host. :-) Bye Servage

I will be sharing a VPS @ slicehost with Ronald and Mattijs

Security Problems Servage

Revived my blog today. It seems my servage account got hacked and some worm destroyed my index.php file. A quick google search revealed that I am certainly not the first.

Time to start thinking about new hosting as this is probably not going to end any time soon.

I was thinking about runnig my own vps so I can also run other services. Anyone (other) suggestions?

Launchpad, Games and Python

Just wanted to let everyone know that I use Launchpad now to host my personal projects. On Launchpad you have your own personal +junk project in which you can host branches that do not belong to a project on Launchpad. In other words it is a perfect playground for little pet-projects. :-)

I’ve been working on a Sub Hunt game lately. It has been amazing how quick you can get a game together with python and pygame. At the time of writing a spend about 4 hours on the game. It is off course very basic and far from finished. But in another 2 - 4 hours it can be almost done. At the moment it contains only three levels, but creating levels is as simple as defining which and how much submarines are in the level.

So check it out and let me know what you think. Ideas on how to expand the game are most welcome. :-)

Internship Update

So nearly another month has passed and I’ve been busy with quite a lot of different things. First my tagging add-on for Hippo ECM is coming along nicely. You can add tags to a document and it pops-up some suggestions beneath them (they aren’t really good suggestions yet but they are there).

To test my tagging add-on I needed some content so I wrote a converter which converts a Wikipedia XML dump into a XML import for Hippo ECM. The script takes the number of articles you want to create in the import as an argument, so I now have imports ranging from a hundred articles to about a hundred thousand articles.

My third project for this month was to create a tag cloud which would enable a user to browse documents by tag.

So after all these details I bring you: The Screenshot :-) (click for a larger version)

Tagging in Hippo ECM

On the left is the tag cloud (needs some layout work still), the center shows the documents with the tag “Living people” and the lower right shows current tags and suggestions belonging to the document.

The suggestion system is quite dumb. It suggests the most common tags at the moment. The coming weeks I will work on a more smart suggestion system. I plan to experiment with:

Enough for now. I need to get back to work :-)

Captcha

I installed a Captcha on my blog to allow anonymous comments. Please let me know if you like it or hate it. Registered users will not see the Captcha so if you hate than registering is an option ;-)

Update: This captcha thing was a complete disaster. I got 200 spam messages within a day after activating it. So I disabled it again :-( Suggestions are still welcome.

Internship @ Hippo

So whats become of me lately? Some of you mite not have heard much of me since the holidays.

Well I’m still here. I’m busy with my internship at Hippo at the moment, so I thought it might be nice to give a headsup on what I am doing here exactly. :-) My internship started back in september and since then I’ve spend quite some time on getting to know the Hippo ECM code base and getting used to Wicket. To accomplish that I wrote a few frontend plug-ins for Hippo ECM. See below for a list of screenshots. Some of them actually got demo’ed. :-)

Shows a list of recent user activity

Show the last 5 uploaden images

During my internship I will write a bigger plug-in. This plug-in will assist users with assigning good keywords (tags) to their content. Basically it will look for related content and suggest the most common keywords from all related content. The system will not create new keywords, but instead feed on the collection of keywords already assigned to the content. No real AI there but more like “Collective Intelligence”.

The challenge is making the performance impact minimal. I will be doing al lot of queries to the backend (Jackrabbit repository) and I don’t want to hammer the thing when just searching for some tags :-)

I’ll post some more screenshots and updates soon, for now my blog software is a bit broken (can’t upload images to my own server and preview post some how seems broken too). I suspect it has something to do with some server reorganisations @ servage some time ago :-(

Zend Certified Engineer Widget

What does one do when he is bored? Write a wordpress plugin. I wanted to update my blog for some time now with my ZCE logo, so I thought why not write a plugin to do so. I noticed that there was a text widget, which doesn’t make it much harder to update your site with the logo, but that is no fun so here is a special ZCE widget.

Feedback is most welcome. Enjoy.