Taking a look at the various API levels available for Android

3 minute read

Introduction

I’m currently getting up to speed with iOS Android (native and Xamarin) and Firefox mobile development. As you can tell from my blog I am still very much in love with Windows Phone but would like to stay abreast with other mobile platforms as well. With that said one thing that confused me when working with Android is all of the different API versions available. I’ve provided a screenshot below of the different emulators you can start with Xamarin.

SNAGHTML72625

The table provided below maps the API level to OS version and name. (I’ve left off 17 which is JellyBean because that emulator image is not installed on my machine).

API Level OS Version OS Name
7 2.1.x ÉCLAIR_MR1
8 2.2.x FROYO_MR1
10 2.3.3 and 2.3.4 GINGERBREAD_MR1
12 3.1.x HONEYCOMB_MR1
14 4.0 4.0.1 4.0.2 ICE CREAM SANDWICH
15 4.03 4.04 ICE CREAM SANDWICH_MR1

The _MR1 stands for “Maintenance Release”. You will probably notice that anything under version 7 of the API is not included. You can still download the image but very few users are using those older devices. It also skips the non-maintenance release images (ex. 9 11 13). You don’t need them on your system if you have the _MR1 as it includes everything in the previous version. More in-depth info can be found here.

The Manifest File

In Windows Phone we have the WMAppManifest.xml. In Android we have the AndroidManifest.xml. Both of these files are similar in nature in that they describe certain aspects of your projects. Relating to the various Android API levels you can specify the minimum API level as well as the target API level.

The minimum API Level is the lowest API that the application will run on. If you are using Xamarin.Android for Visual Studio 2012 you can select the project properties and set it under the “Application” tab. One thing to note is that it list the “Minimum Android to target” instead of the API Level. If you look back at my chart then you will see this maps to API 8.

image

The target API Level specifies the API Level on which the application is designed to run. In some cases this allows the application to use manifest elements or behaviors defined in the target API Level rather than being restricted to using only those defined for the minimum API Level. This can be set in the “Android Manifest” page in the project properties in Visual Studio 2012 as shown below. This time it provides the API level to select from.

image

Note: A AndroidManifest.xml file is created automatically for you using Xamarin. Upon first click of this tab you will need to create one if you want to customize this.

Taking a look at the Completed Android Package File.

Once compiled you will find the apk file in the “bin” folder as shown below. One is signed and the other is not. Make a copy of the unsigned one and rename it to .zip to view the contents. 

image

Here is the contents of the hello.world.apk. We are only interested in the AndroidManifest.xml file so you can ignore the others for now.

image

If we try to open the AndroidManifest.xml in notepad then we obviously can’t read it with the naked eye:

image

This is where we can make use of a tool supplied by Android called aapt.exe (Android Asset Packaging Tool) found in the C:\Users\<Your User Name>\AppData\Local\Android\android-sdk\platform-tools folder.

Simply run this command in a command prompt with the .apk file copied to this directory. An example of the command can be found below.

aapt l –a packagename.apk

Scroll down until you find the “uses-sdk” as shown below.

image

Leave a Comment