Deploying to Android is using the wrong dll

Kevin Delval 176 Reputation points

I have recently started creating a multi-platform PCL with all manner of views, effects and other Xamarin utilities for use in any number of projects. Because some of these have platform-specific code and I do not want to include Android dependencies on iOS, for example, I decided to make this target different frameworks.



When I build this library, it correctly creates two output folders where the dll in the monoandroid folder contains the implementations specific to Android, and the netstandard2.1 folder does not.

However, after adding a project reference to this PCL for my Sample project (which I keep in the same solution), it seems to always pick up the netstandard2.1 dll, instead of the Android one.



After using dotPeek to look into the dll placed in the bin folder of my Sample.Android project, I've confirmed that it's the one built for the netstandard TargetFramework.

What could be causing the Android project to pick up the wrong .dll? I have a suspicion is might be a limitation with Project References and that I might need to reference a NuGet package instead. That would be rather annoying for testing though...

Any help would be welcome.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,006 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,196 questions
0 comments No comments
{count} votes

Accepted answer
  1. JarvanZhang 23,876 Reputation points


    Welcome to our Microsoft Q&A platform!

    TargetFramework is not supported to set as MonoAndroid, you could right click the shared project -> Properties, to check the value list of this option.

    Because some of these have platform-specific code and I do not want to include Android dependencies on iOS

    The default value of Condition will apply the configuration according to the running platform. It'wll not include a native dependencies to another platform.

       <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">  

    You could check the reference of the platform project. For example, Android project does not reference the iOS project.

    Best Regards,

    Jarvan Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful