Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
752 views
in Technique[技术] by (71.8m points)

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

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 Studio2019CommunityMSBuildXamarinAndroidXamarin.Android.Common.targets(2816,3): error : java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...