Home: Wrong TFM for PackageReference in Android Class Library

Created on 6 Jan 2021  路  3Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used: VS UI
NuGet version: 5.8.0
VS version: VisualStudio.16.Release/16.8.3+30804.86
OS version: Windows 8.1 x64

Detailed repro steps so we can see the same problem

  1. Create Android Class Library in MSVS for Windows

  2. Add a Nuget PackageReference that has several TFMs. In my case it is MvvmCross 7.1.2 that have TFMs:
    .NETCoreApp 3.1
    .NETFramework 4.6.1
    .NETStandard 2.0
    MonoAndroid 10.0
    Tizen 4.0
    UAP 10.0.16299
    Xamarin.iOS 1.0
    Xamarin.Mac 2.0
    Xamarin.TVOS 1.0
    Xamarin.WatchOS 1.0

  3. Use any type that is Android specific (ex. MvxAndroidViewPresenter)

  4. Your lib will not compile, type is missing. The reason probably is that _netstandard2.0_ TFM is used instead of _monoandroid10.0_

Sample Project

https://github.com/Paul-N/AndroidClassLibDemo

Question

All 3 comments

Yes, changing Android version from 9 to 10 is solved the problem. Maybe it worth to warn user about his lib's Android version or update Android Class Library template supplied with MSVS. Anyway you're right, it's not a Nuget problem.

We're working on a way to tell you if a package is compatible or not with your application and we may be able to prompt you to update your TFM if we notice you're not on the latest version the library supports.

Was this page helpful?
0 / 5 - 0 ratings