Android Futures: Preparing For Ice Cream Sandwich

The next major version of the Android SDK, codenamed Ice Cream Sandwich, is due out within the next couple of months. While we’re waiting for the release, here are some quick tips to future-proof your applications.

Ice Cream Sandwich is a highly anticipated new Android SDK release that is expected to marry the Gingerbread and Honeycomb revisions in a single, unified platform for all Android devices, large and small. Here are some tips for preparing for the new revision, which by many accounts, is expected to be a great leap forward for the platform. And as all developers know, great leaps forward often signal difficult times for legacy applications.

When You Assume…

The Android development team releases Android SDKs on a regular basis. But, like any technical project, there’s no guarantee of its shipping features until the code goes live. As a developer, it’s important to understand what this means to you and communicate it to your management.

The Android team is a relatively closed-mouth group. Android may be open source, but the development is not open. It means that whatever you’ve heard about the next revision of the Android SDK (in this case, Ice Cream Sandwich or ICS) is pure speculation, until Ice Cream Sandwich is released and we see it with our own eyes. So understand this: the media may be telling you all about what’s in ICS, but they’re really just guessing, or speculating.

Even if you’ve gotten a peek at the release candidate, or know someone who has, it’s only a candidate…Features get shuffled, deferred, or dropped at the last minute if they’re not ready for prime time. Once the platform is stable and well tested, it will be released.

No one is even sure what version number ICS will be: Android 3.3? Android 3.5? Android 4.0? Our personal guess is Android 4.0 as it’s considered a major new release, and we’re pretty sure it will be API Level 14, but no promises.

When will it be released? Well, at Google IO 2011, the answer to that question was “Q4, 2011.” A recent statement by Google’s Eric Schmidt stated we can expect it in the October/November timeframe. Again, it’ll be here when it gets here. Sometimes releases come early, sometimes they are held up for weeks if something comes up last minute. It’s a good bet we’ll see it before Christmas.

How Do I Work With This Uncertainty!?

Well, there’s some good news here. Developers usually have a chance to get their hands on the Android SDK before it gets rolled out to users. So, you’ve usually got some time after release to iron out any issues with your applications before your users run into problems, provided you stay on top of the releases by watching the Android SDK website (http://developer.android.com or just http://d.android.com) and reviewing your apps in a timely fashion.

The Android team also does a reasonably good job of providing backwards compatibility in new Android SDK releases. This means that if your applications worked well on previous platform versions and don't do anything sneaking or undocumented, they will probably work well enough on the new version…it just won’t take advantage of anything new that ICS has to offer. For that, you’ll need to review what’s new once the platform is released, and update your application accordingly. Therefore, it’s best to budget some time prior to release to address existing issues, as well as some time after the ICS release to upgrade your applications to take advantage of ICS-specific updates.

The last bit of good news is that carriers often hold off on firmware upgrades for a while after a new Android SDK is released. In fact, it can sometimes be a challenge to acquire physical devices running the latest SDK at the time it is released. So again, the chances that your users are dabbling in ICS before you are is very low (And the rumors of the Nexus Prime are even muddier than ICS.).

Now, let’s look at some ways you can future-proof your applications and help prepare for Ice Cream Sandwich.

Tip #1 The More Recent Your App Target Is, The Better

It’s safe to say that the newer your application build target, the better off you’ll be. If your application was written for Android 1.5, you’re more likely to need to jump through a lot more hoops than if your application is already targeting Android 2.3 or 3.2. So now is the time to bring your applications forward to the latest standards you do know about.

Your Android 1.5 application may work, but each release has increased the amount of items that you can do to make it work better. ICS will likely be no exception to this. But more people will have ICS than have Honeycomb, which introduced such things as "compatibility zoom."

Tip #2 The Compatibility Package is a Big Hint of What’s to Come

Ice Cream Sandwich is supposed to be the version that merges the latest “smartphone-style” SDK (Android 2.3, Gingerbread) with the latest “smartdevice-style” SDK (Android 3.0-3.2, Honeycomb). By smartdevices, we mean tablets, TVs, and other such devices. You may have noticed the compatibility package was introduced a while back to help with the fragmentation problem. This package allows legacy Android SDKs access to some of the newer features of the platform, such as:

Fragments

Loaders

Action Bars

Updated MotionEvent, VelocityTracker, ViewConfiguration classes

These features don’t just allow your legacy devices to enable some of the newer Android SDK features; they’re also showing the direction in which the Android developers are going. Start considering how your legacy applications can use these features now, before they become so ingrained in application development that you need to completely redesign your application to keep up.

Tip #3 Deprecated Classes and Methods Are Another Big Hint

As the Android platform matures, best practices for application development change. For example, it used to be highly recommended to let your Activity class manage your cursors using the startManagingCursor() and stopManagingCursor() methods. Now these methods are deprecated and a LoaderManager/CursorLoader solution is recommended instead.

Here’s another example: Activities used to manage their dialog pool using a number of dialog-based callback methods. All dialog methods in the Activity class are now deprecated. Instead, a FragmentManager/DialogFragment solution is recommended instead.

Review your application and see what deprecated methods are being used. By implementing the newer, recommended solutions, your applications are more likely to play well in new versions of the Android SDK. You can find out what’s changed in a specific Android SDK revision by reviewing the API Diff Report. For example, this is the API Diff report for the changes in the Activity class for API Level 13. Eight methods are deprecated in just this one class.

Tip #4 Follow Android Best Practices in General

Dorothy in the Wizard of Oz learned her lesson when she left the Yellow Brick Road. The same is true for Android developers. When you follow Android best practices, your applications are more likely to remain compatible with future versions of the Android SDK, simply because they conform to the behaviors expected by well-designed applications.

Hacks, exploits, and use of undocumented APIs are danger areas any time the Android SDK is updated. As a major new revision, Ice Cream Sandwich is more likely to shake things up than a minor firmware upgrade would. Now is the time to fix up any weak areas of your application that do not follow best practices. You might have needed that hack early on, but make sure there’s not a better way now. A good example of this is older legacy applications that do not use the proper methods to detect and react to orientation changes.

We’ve got a number of Android best practice tutorials available right here on Mobiletuts+ for you to review. You can also find more on the Android developer website.

Tip #5 Solidify Your Application Requirements

Review all the Android manifest settings and make sure your application is very specific about its requirements. If the app needs certain hardware features, or supports only a subset of all screen sizes and resolutions, make sure these settings are properly reflected in your application’s Android manifest file. Many of these settings were not available in early Android SDKs, so if your application is an older, legacy application, it’s worth an update for just this purpose.

For most manifest changes, simply changing the target SDK while leaving the minimum SDK is sufficient, but be sure to test. The compatibility layers internal to Android can change some behavior based on the target SDK version.

Tip #6 Re-test Your Assumptions, Especially About Device Features

In all likelihood, your legacy applications were written with either smartphones or smartdevices (e.g. tablets) in mind. Therefore, there may be coding and user interface design assumptions built into your application design. For example, you may assume that all devices have telephony features, or a camera, or a GPS.

These assumptions may have seemed reasonable at the time, but with ICS set to “sandwich” the smartphone and smartdevice SDKs into one delightful package, now is the time to rethink them.

Are you testing for hardware or API availability prior to trying to access these features or services? Does your application fail gracefully when these services don’t exist? Now is the time to test these assumptions, implement alternative functionality for the cases when your assumptions are wrong (even if it means gracefully shutting down the app).

Tip #7 Hope for the Best, Plan for the Worst

Ideally, your app will run just fine on ICS without any changes at all. However, if your application does falter, it’s best to have a backup plan. These days it’s easy to exclude specific Android SDK versions using Android manifest file settings and Android Market filters. You can now exclude specific devices when publishing to the Android Market system, too. You’re better off not supporting devices than crashing and burning and ruining your application ratings by not excluding incompatible devices.

Conclusion

Hopefully these coding tips will help to make the transition smoother and more straightforward, so that you’re a step ahead of the game when the Ice Cream Sandwich release hits the website later this year. What SDK features are you hoping to see in this widely anticipated upcoming release? Drop us a comment and let us know!