Bug 5132 - Fleshed out Android.OS.Build.VERSION_CODES regardless of compile target
Summary: Fleshed out Android.OS.Build.VERSION_CODES regardless of compile target
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-05-16 18:08 UTC by adam.lickel
Modified: 2012-05-30 12:17 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description adam.lickel 2012-05-16 18:08:43 UTC
I should be able to reference Build.VERSION_CODES.IceCreamSandwich regardless of whether I'm building for Froyo or ICS.
While it's easy enough to just use the raw int and cast it to the enum, it'd be far cleaner to just use the enum directly.

This is especially an issue because you have to compile at the lowest version of the OS that you support, otherwise certain classes are unusable (e.g. MotionEvent).
This is different from Java where you can compile with the most recent SDK, but can't use the newer APIs (e.g. InputEvent). The constants are compiled in, so it is safe to use them regardless of the OS.
Comment 1 Atsushi Eno 2012-05-30 12:17:05 UTC
It is totally doable with current MfA 4.2. MotionEvent issue is gone: http://docs.xamarin.com/android/Releases/Mono_For_Android_4/Mono_For_Android_4.2#Improved_API_level_support

I assume you already know this, but to achieve what you want - in the project properties, Set target Framework to 4.0.3 (API Level 15), and set Minimum Android Version as you want (e.g. API Level 4) in "Mono for Android Application" subpage (you'll have to "create" it first to set this version info). Unlike earlier versions it should just work on older platforms.