Hello,
The condition statement you set is correct, and you can refer to the following full item group:
(AndroidCustomLibrary
is the name of an Android Class Library project)
<ItemGroup >
<Reference Include="AndroidCustomLibrary" Condition="'$(TargetFramework)' == 'net7.0-android'"><!--or Condition="$(TargetFramework.StartsWith('net7.0-android'))"-->
<HintPath>..\AndroidCustomLibrary\obj\Debug\net7.0-android\AndroidCustomLibrary.dll</HintPath>
</Reference>
</ItemGroup>
It's the default behavior that the reference was also added to every Platform dependency. However, it's not available when you use the namespace. When I type using AndroidCustomLibrary;
in MainPage
, there will be a warning button that shows it's not available on iOS and Maccatalyst.
For this, you can try conditional compilation:
#if ANDROID
using AndroidCustomLibrary;
#endif
Or sending feedback with VS, please see Report a problem or suggestions for Visual Studio for Mac Best Regards, Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 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.