I am using a multi-targeting library in my Xamarin forms application. The library has come code written with __ANDROID__
conditional compiler symbol. When i run the application on Android, it does not execute the code written with the symbol.
The multi-targeting library project is using MSBuild.Sdk.Extras.
<Project Sdk="MSBuild.Sdk.Extras" ToolsVersion="16.0">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;MonoAndroid90</TargetFrameworks>
</PropertyGroup>
I also tried it by defining conditional symbol in Xamarin.Android Project Properties --> Build --> General --> Conditional compilation symbols. But it still does not run that particular code.
#if __ANDROID__
// do some andoid specific work
#endif
It should run this code block when running the application on Android.
Copyright Notice:Content Author:「Zohaib」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58237698/code-written-in-cross-platform-library-with-android-does-not-execute-in-xama