How to fix java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes

后端 未结 1 590
甜味超标
甜味超标 2021-01-27 17:13

There is no means to resolve the conflict between. I tried uninstalling Visual Studio, repairing Visual Studio but still useless.

\"mscorlib, Version=4.0.0.0, Cu         


        
1条回答
  •  旧巷少年郎
    2021-01-27 17:41

    Thanks to the comment of Leon Lu - MSFT, I solved it on my part. When I was updating packages to be used in my Xamarin.Android project I unintentionally installed: Xamarin.Android.Support.Core.UI and Crosslight.Xamarin.Android.Support.Core.UI which in turn gave me the error:java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes

    I cleared my nuget cach and removed the "Crosslight.Xamarin.Android.Support.Core.UI" which solved it on my part.

    I wasn't able to use the step that Leon Lu - MSFT proposed, but I did the eqvivalent with commands. As you can see in the steps underneath.

    * Try this first * Before you start these steps I would double check if you have any NuGet-packages which my cause package duplication, remove it and do a build.

    If this does not work then try these steps:

    1. Open the solution that you have a problem with in VS.
    2. Go to Tools > NuGet Package Manager > Package Manager Settings -> General and hit the "Clear All NuGet Cache(s)
    3. This should return an error because you have an project open, but if not then skip to step: 6
    4. Do not close the solution yet, but open "Run" (Windows key + R) and type "cmd" and run these commands: Clearing Local Folders - Microsoft Docs
      • dotnet nuget locals http-cache --clear
      • dotnet nuget locals global-packages --clear
      • dotnet nuget locals temp --clear
      • dotnet nuget locals plugins-cache --clear
    5. Command 2 and 4 should give you an error, which in turn will give you a hint about what packages is in use and may be the reason for the error.
    6. Now close the VS Solution and run the fail commands. Now all of the commands should have been run successfully.
    7. Open your solution again. Remove the NuGet which creates the duplication and try to build the solution again.
    8. Now you should be able to build your project without the error: java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes

    Hope it helps!

    0 讨论(0)
提交回复
热议问题