问题
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, Culture=neutral, PublicKeyToken=b77a5c561934e089" y "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Se elegirá "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" de manera arbitraria.
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnimatorRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnyRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AnyThread;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/ArrayRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/AttrRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/BinderThread;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/BoolRes;
1> Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/annotation/CallSuper;
1>
1> UNEXPECTED TOP-LEVEL EXCEPTION:
1> java.lang.RuntimeException: Translation has been interrupted
1> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:614)
1> at com.android.dx.command.dexer.Main.runMonoDex(Main.java:310)
1> at com.android.dx.command.dexer.Main.runDx(Main.java:288)
1> at com.android.dx.command.dexer.Main.main(Main.java:244)
1> at com.android.dx.command.Main.main(Main.java:95)
1> Caused by: java.lang.InterruptedException: Too many errors
1> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:606)
1> ... 4 more
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2816,3): error : java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes;
回答1:
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:
- Open the solution that you have a problem with in VS.
- Go to Tools > NuGet Package Manager > Package Manager Settings -> General and hit the "Clear All NuGet Cache(s)
- This should return an error because you have an project open, but if not then skip to step: 6
- 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
- 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.
- Now close the VS Solution and run the fail commands. Now all of the commands should have been run successfully.
- Open your solution again. Remove the NuGet which creates the duplication and try to build the solution again.
- Now you should be able to build your project without the error: java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes
Hope it helps!
来源:https://stackoverflow.com/questions/57001363/how-to-fix-java-lang-illegalargumentexception-already-added-landroid-support