Martijn
Martijn

Reputation: 392

Xamarin Targetframeworkversion

I am trying to make a basic Xamarin.forms (pcl) application (in Visual studio 2017) and i want to Target Lolipop (5.0.0, api level 21).

So i made a basic Xamarin solution and i adjusted the Android properties all to Android 5.0 lollipop

Unfortunately in my warning list i get the following

Severity Code Description Project File Line Suppression State Warning The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.dll (v7.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project. Prolang.Android C:\Projects\Prolang\Prolang\Prolang.Android\Prolang.Android.csproj

If i google for this error most people say to indeed update your android project to use the latest Targetframework version. But in my case i really want to only be able to call Api calls that are available to level 21 aka Android 5.0 Lollipop. As in i want the compile time safety net that i only use Api Calls from Api level 21.

To me it seems like i have to downgrade my xamarin.Forms dll to a version that is made specifically for android lollipop since the one i use right now targets a higher version.

So should i downgrade my xamarin.forms dll to achieve this and get rid of the error? And if i downgrade to what version do i need to downgrade so i target Android 5.0 Lollipop? This information is all pretty unclear to me.

Upvotes: 1

Views: 2950

Answers (1)

SushiHangover
SushiHangover

Reputation: 74104

Xamarin.Forms is designed using the Android's support libraries so it will run on a wide range of APIs without any additional actions from the developer.

If you are using native APIs via Xamarin.Android (assumably via Forms' Dependency Service) then yes you would have to be aware of the API level of the method calls.

That said, since Xamarin.Forms uses the com.android.support.* libraries and you would have to have to a Forms versions that uses com.android.support:design:21.x.x and the associated Android build tools for API 21.

Now you can review the package dependancies and you will see that your choices are Forms' is 1.4

`1.4.0.6336-pre1` to `1.4.4.6449`

Note: v1.5.x moved to version 22 of the Android support libraries

IMHO using Forms's 1.4 would a bad mistake due to its age and the mountain of improvements and bugs fixes since 2015, you are so much better off:

  • Using the latest Forms version
  • Set the Framework version to latest (7.1)
  • Set the Target Android version to Android 5.0 (API Level 21)
  • Set the Minimum Android version to whatever you need...
  • Forgo the compile time API checks
  • Check runtime API issues via API-21 devices and emulators

Upvotes: 1

Related Questions