A Few Tips for Beginning Android Development
Join the DZone community and get the full member experience.Join For Free
here are a number of tips from my personal experience so far with android development. the number of tips is actually ten, so i could have called this " ten tips for android development ", but i figured there were already enough articles with that catchy title. which reminds me of late comedian george carlin :
i have a problem with the ten commandments. here it is: why are there ten?...why not nine, or eleven? i'll tell you why. because ten sounds important. ten sounds official. they knew if they tried eleven, people wouldn't take them seriously. people would say, "what're you kiddin' me? the eleven commandments? get the f*** outta here!"
ok, now that i opened up with a joke, let's get into more serious stuff...
1. choice of ide
most of the android development is centered around eclipse, although i coded a few applications using intellij idea's community edition without any problem. personally, i don't care much about eclipse's ui drag-and-drop interface. which is anything but impressive. way more work needs to be done here.
2. develop for the masses
all of us would just love to use the latest android version with all the cool new stuff. unfortunately, the android smartphones on the market don't exactly follow the speed of official version releases. so before diving into coding, do a preliminary check . an application written for the older versions works with the newer ones, but the reverse is of course not true. at this time, version 2.3 ( gingerbread ) is still the dominant one. so you might want to wait a while before biting into an ice-cream sandwich.
3. forget the emulator, get the real deal
forget the emulator. it's painfully slow, and you can only test a limited number of things on it. i use it only to test how my apps look like on bigger screen sizes, and that's about it. so, if you want to save time, use a real device connected via usb. i'd say you actually need two devices, since odds are, you'll have to test things like sms, bluetooth, and anything else requiring device-to-device communication. even better if your second device has a different screen size. the more different the devices, the better you can test your app.
4. don't like xml? too bad
all of android's ui is based on xml, which caused most of my initial headaches when i started. although there are some tools that can assist you with some aspects of the ui, like action bar generators (such as the sherlock , or the one from johannilsson on github), i am not aware of a complete gui builder at this time, that would do all the low-level work and not be a leaky abstraction . all the visual editing tools i tested were buggy or incomplete. if you happen to know a decent one, please let us xml-wary folks know.
5. use modular ui structure
the amount of xml needed to build a decent ui can become quickly...daunting. therefore, build components for reuse between different layouts as much as you can, using includes and fragments . fragments were introduced in version 3.0, but you can download support libraries if you are developing for earlier versions.
6. you need a designer
or you need to become one yourself. there are a few online facilities for adding common gui elements to your app, like the android asset studio , but if that's not enough, you'll need to design your own, adapting for different screen intensities. be sure to also read the official android design guidelines.
7. use android-specific solutions where applicable
the android-specific solution is usually simpler and/or yields better performance. taking multi-threading & asynchronous processing as an example, consider using an intentservice or asynctask before looking at the java.util.concurrent package, although in some cases, the latter might ultimately be the way to go.
8. google is still your friend
although the amount of documentation on the android developer official site is extensive, it is often faster to just google what you're looking for. as a concrete example, here's a result search on deleting sms messages on arrival at stack overflow that gives more insights than the official docs.
9. beware of miracle tools
without mentioning a specific one, be wary in general of products that pretend to ease smartphone development across the board (android, ios and blackberry rim, all at the same time). i am not saying they are all crock, but be sure to test them first by developing a simple yet significant app and deploy it on all of them. each display should look like a native app on that os. of course, if you are only developing a web app for mobile devices, you need not be overly concerned by this.
10. all good software practices still apply
test extensively (using
, for example), design for i18n and
, use design patterns etc.
at a very bare minimum, you should make an effort to separate ui code from your business logic, even for the smallest applications. not doing so is just asking for trouble down the road.
developing on android is an exciting experience, in spite of all the frustrations caused by imperfect or non-existent tools. but that is sort of logical in a relatively new environment. the bright side is, things should get better over time, and fast.
Opinions expressed by DZone contributors are their own.