Android is a platform that for better or for worse runs on wide variety of devices and causes a lot of “fragmentation” complaints by less experienced developers. And while the screen/resolution issues can be decently solved by having a competent designer (see: web development), version fragmentation poses a more significant problem - only 7.1% of all Android devices run 4.x versions, while the rest are suck on older Androids with little hope for update.
Ice Cream sandwich (and Honeycomb before it) brought significant improvements to the Android API, which significantly ease cross-device development and thanks to efforts of several developers a large part of those changes were backported in form of libraries for Android 2.x.
The most headache-easing libraries for Android development I’ve found so far are:
- Fragments add a way to manage only part of displayed activity life-cycle and are critical part of tablet user interfaces - especially if you want to develop apps which work on phones and tablets without publishing separate APKs.
- Loaders are a high-level interface for retrieving data from slow sources (network or database). Android runtime caches the loaders by their ID across Activity life-cycle, which means easy management and caching of remote data without writing boiler-plate AsyncTask code to keep state across orientation changes.
Action bar is a new Android paradigm, which is composed of a top bar with application name and implements tab navigation, menu replacement and “up” navigation. Pretty much any Android app has an action bar (or at least should have) and this API is the easiest way to implement it. It also handles tab navigation with optional split mode (you should not use TabHost anymore) and menu buttons on devices without physical keys (e.g. Galaxy Nexus) and moves icons to menu when screen space runs out.
More details of how to use action bar (and why it’s important) are available on Android Design page.
Seriously, if you’re not using it yet, you should.
Action Bar Style Generator is a nice little web tool by Jeff Gilfelt, which generates styles and 9-patch images in selected colors. It’s compatible with before-mentioned ActionBarSherlock library and is a must-have if you want custom branded application.
Android animation pre-3.x was very clunky and required XML files to do anything useful. Honeycomb made everything easier (but not perfect) by introducing view property animators. This is thus a must-have for an app that wants to be compatible with 2.x and visually appealing at the same time.
Pull-to-Refresh allows you to implement the iOS-ish paradigm of pulling a ListView to refresh content.
NOTE: Pull-to-refresh is a distinctly non-Android way of refreshing content, I suggest adding a separate “Refresh” option to the menu (e.g. like Boid Twitter client) to avoid user confusion.
RoboGuice is a dependency-injection framework for Android, which works perfectly for Android UI elements and services. It helps eliminate all those pesky findViewById(), getIntent().getExtras() calls littering the Activity code, making it more readable and (because of some added checks) less error-prone.
There were some problems using both RoboGuice and ABS in the same project (since both extend the Activity class), however this issue has been fixed in latest version of ABS see example on ABS GitHub.
Android Support Library also adds support for horizontally scrolling ViewPager, which allows you to put several fragments side by side and allow user to swipe between them. However, the API is missing a position indicator similar to the one in Google+ and Play Market apps. Such customizable indicator is provided by ViewPagerIndicator library.
Noone in their right mind would say Java is a concise language - it often needs alot of boilerplate code to do things. AQuery is a library that tries to fix this problem by adding a more fluent API over Android platform API, cleaning up your codebase.
Thanks to Damjan Malis for last two suggestions.
That’s it for now, if there are any other great Android libraries I’d be happy to know.Continue reading