Open Susko3 opened 1 month ago
Unfortunately this is a historical mistake that would cause too much breakage if we fixed it now.
There is a lot of history/discussion/workarounds related to this issue here: https://github.com/xamarin/XamarinComponents/issues/1176
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
MSBuild version 17.9.8+b34f75857 for .NET 8.0.204
Description
First noticed in https://github.com/ppy/osu/pull/27179/commits/9c22fa3a9fbae0fb568e5a7b36d4c688268add3a.
The java binding for
org.jetbrains.annotations
(named Xamarin.Jetbrains.Annotations) uses theJetbrains.Annotations
namespace. This directly clashes with the .NET JetBrains.Annotations which also uses theJetbrains.Annotations
namespace.This namespace clash is apparent when using a type that is defined in both the Java and in the .NET version of the library. For example,
NotNullAttribute
.Offending line that produces the clashing namespace:
https://github.com/xamarin/AndroidX/blob/3c8325e40f151719f5d3e5a3c34baa56b0b88bb5/Directory.Build.props#L74
As for fixing this issue, I suggest you change the namespace for the java binding. I don't think the types from the java library are meant to be used in application code, so the name of the namespace probably doesn't matter.
Steps to Reproduce
JetBrains.Annotations.NotNullAttribute
namespace AndroidLib1;
public class Class1 { public void Test([NotNull] object obj) { } }
Did you find any workaround?
Add this to the project. Taken from https://stackoverflow.com/questions/9194495/type-exists-in-2-assemblies/65127159#65127159.
Relevant log output