Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
Detect API level incompatibilities in Xamarin Android App (Visual Studio 2015) at compile time instead of runtime

I am writing a Xamarin Android app using Visual Studio 2015 (Windows). I want to target the latest Android API, while maintaining backwards compatibility to API 16 (4.1 Jelly Bean).

I know how to ensure there is no run-time error thrown via an API level check:

if(Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
    //Call API supported by Lollipop and above, but not by lower API's
}
else
{
   //Alternative code for graceful backwards compatibility
}

Unfortunately, if I don't have this check, Visual Studio still happily compiles and runs my code - and if the API is not supported, I get a run-time Java.Lang.NoSuchMethodError exception. I can manually reset the project to a lower level API to catch the errors compile-time, but this is a bit cumbersome - it would be great to catch these errors (even as warnings) at compile-time, without manually resetting to each lower API I'd like to support.

How can I detect an incompatible API call at compile time?

NOTE: I did find a similar question on StackOverflow, but it specifically addresses Xamarin Studio for Mac - which suggests this should be possible to do in Visual Studio 2015 for Windows (2017 solution ok too).

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!