[mono-android] API version compilation benefits

Jonathan Pryor jonp at xamarin.com
Wed Apr 4 16:06:30 UTC 2012

On Apr 4, 2012, at 6:41 AM, Goncalo Oliveira wrote:
> Can anyone tell me if and what are the advantages of compiling an app for a higher version?

The advantage to targeting a higher version is that you can access and use types and members added in that API version, e.g. to use Fragments you need to target API level 11+ (Android v3.0+). If you're not using those types and members, there is no advantage to targeting a higher API level.

Furthermore, your 2.3.3 build will run w/o issue [0] on higher API level devices (tablets, Android v4 devices). The reverse -- running a 3.1 build on a 2.3 device -- will very probably fail in obscure ways [3].

If you want to support both existing API10 phones and tablets and the forthcoming ICS phones, you'll need to think about what you want in terms of "support":

- Run? Targeting API 10 will run on all API10+ devices.

- Run + Look good? You'll need some flavor of target-specific UI. This can be done either via separate layout files [0, 1, 2], through multi-APK support [4] (build one .apk for API10, build another for API 12, etc.), or through use of the compatibility libraries. Unfortunately, easy use of the compatibility libraries will need to wait for the forthcoming 4.1.0 alpha release.

 - Jon

[0] One "issue" is that running a phone UI on a tablet results in a fugly UI. This can be rectified by providing tablet-specific UI .axml files [1, 2], e.g. via Resources\layout-xlarge\MyLayout.axml

[1] http://developer.android.com/guide/topics/resources/providing-resources.html

[2] http://developer.android.com/guide/practices/screens_support.html

[3] http://lists.ximian.com/pipermail/monodroid/2011-November/007350.html

[4] http://android-developers.blogspot.com/2011/07/multiple-apk-support-in-android-market.html

More information about the Monodroid mailing list