question

KevinDelval avatar image
0 Votes"
KevinDelval asked JarvanZhang-MSFT edited

Deploying to Android is using the wrong dll

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.

136360-image.png

136290-image.png

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.

136270-image.png

136391-sigmaxf-microsoft-visual-studio.jpg

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.

dotnet-csharpdotnet-xamarinforms
image.png (3.8 KiB)
image.png (25.7 KiB)
image.png (3.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT edited

Hello,​

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'">
  <DebugType>portable</DebugType>
  <DebugSymbols>true</DebugSymbols>
</PropertyGroup>

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.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.