#52WeeksOfCode Week 11 – Android

Week: 11

Language: Android

IDE(s): Eclipse for Android

Background:

Android developers have both a huge opportunity and a huge problem. Both of these can be laid directly at Google’s doorstep as they spring straight out of Google’s Android Strategy:

1. Create a mobile operating system that is ‘good enough’ and give it away at no cost.

2. Let others modify the platform any way they want

Number 1 means that Android gets wide distribution very quickly. Last year Android devices made up almost 80% of global smartphone shipments and according to Google’s numbers there are 900 million Android devices out in the wild. Great news! Sounds like becoming an Android developer is a license to print money with all of those potential customers out there.

Not so fast, Hoss.

The problem comes with step 2. Smartphone companies get to decide for themselves what version of the operating system to use and what features they’ll support. So those 900 million phones are not all running the same OS and so your choice is to either support every active version available (thus costing you money and time) or just support the latest versions (plus or minus a release or two) and cut down on your potential customer base.

This isn’t even going into the problem of fragmentation on the hardware side. Storage capacity, memory size, screen sizes and resolutions…so your app still may not work on all devices even if they’re running a supported version of the OS. The major problem with Android (particularly for Android developers) is fragmentation.

Google, however, has an idea that they think will fix this. Simply put, they plan to restrict access to Google Mobile Services (GMS) to devices that ship with up-to-date versions of Android. So if you’re a smartphone maker and want to be able to ship apps like Google Maps, Google Drive, Google Play, Google Calendar and Gmail, you’re going to need to make sure you comply.

Great idea. There’s one teensy little problem, though. You don’t have to ship Google apps with your Android device. That’s exactly what’s happening in China, which has almost 300 million Android users, 70 percent of whom don’t use Google apps.

Oops.

I want to be clear, this is not some kind of anti-Android or anti-Google screed. I have an Android phone and I rely on Google apps quite heavily (I’m typing this post in Google Docs, for example).

The reason China is rejecting GMS is because China and Google are having a fight over China’s censorship of Google search results.

So maybe the problem is about control. Perhaps if you want to give away software (and please note I’m a big fan of Open Source and Free Software), maybe you have to be willing to give up control and rely on what value you can provide through services and have your services compete openly with others rather than try to lock in your customers and rely on that to control them.

But I’m just a Simple Country Lawyer. (Metaphorically speaking.)

Discussion:

Getting the Android Software Development Kit (SDK) was pretty easy. You can do your development on Windows, Mac OS X or Linux and you can even use your own IDE, as long you download and install the SDK tools and whatever other Android packages you’re going to need.

I decided to go with the full bundle, so after I agreed to the Terms and Conditions, I went ahead and grabbed the approximately 450 MB download of the Android development platform for my MacBook. And though I have an Android phone, the kit comes with a software emulator so I won’t have to risk bricking my smartphone.

Android software uses the Java programming language and the IDE of choice is Eclipse. (You can also use the SDK tools from the command line but you’re still going to be programming with Java.) The download was a ZIP file consisting of two folders, eclipse and sdk. I followed the setup instructions and unpacked the ZIP in a folder called Development.

When I launched Eclipse, I was given a window with a button labelled “New Android Application” and three tutorials, “Build Your First App”, “Design Your App” and “Test Your App”. Selecting “Build Your First App” takes you to the Android Developer tutorial page where you’ll begin a walkthrough.

Like most modern IDEs, Eclipse has a New Project wizard that walks you through setup in order to make sure that you don’t miss anything. For this tutorial I created a project called “My First App”.

First problem – the simple act of creating my app (remember, I haven’t built or run it yet) generating a list of errors 337 lines long. This does not bode well. The full error log is here, if you’re interested. I’m going to soldier on, however.

One of the features that interests me about mobile application development is being able to test your app in a virtual device. As I’ve said, I have an Android phone but I’d like to try the emulator first.

The primary advantage of using the emulator is that you get to test your app on different hardware models with different versions of the Android OS. I launched the Virtual Device Manager (VDM) from the Eclipse toolbar and the first thing I see is a window with six error messages in it about multiple virtual devices that failed to load. As I haven’t created any devices yet, these may be older versions of the API that were not included as part of the SDK I installed. So I soldier on.

The next thing I notice is that my model phone is not on the list of devices available. I have an Galaxy S3 and the nearest I can find is the S4 so I pick that. The only Android API version available to my emulated device is level 19, which might explain why the other versions failed to load earlier. For the rest of my options, I take the defaults. My VDM window now shows that I have a valid Android Virtual  Device. I select the device, click on ‘Start’ and shortly a window pops up and I get what looks like an Android boot screen. At first it looks like it’s not doing anything but in a couple of minutes, I get a home screen. It’s a little pokey, but that’s to be expected. I have to use my laptop keyboard for the controls but the Android folks provide a helpful table for this.

The first run didn’t work but once I closed the emulator window and ran the app again it did.  Here’s what it looks like:MyFirstApp.png

Overall, it looks like getting started on Android development is fairly straightforward, as long as you ignore the Looming Spectre of Fragmentation (as discussed above). Like everything else, there are still issues. But, as the Buddha says:

What is the noble truth of suffering? Birth is suffering, ageing is suffering and sorrow and lamentation, pain, grief and despair are suffering.

He was a pretty fun guy.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s