Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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).

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda