java.lang.IllegalArgumentException compiling to Android 9.0

GaryBergGaryBerg USMember ✭✭

I start up a Visual studio 2019 project right from an empty project template "create a mobile app", up the target framework to Android 9.0, compile the android project, then I get this error. Can anybody help? How can I use the 9.0 framework? I have also gotten this error with Visual studio 2017.

Error:
"java.lang.IllegalArgumentException: already added : Landroid/support/annotation/AnimRes; "

Output:
1>------ Build started: Project: ChatGames.Android, Configuration: Debug Any CPU ------
1> ChatGames.Android -> C:\VS\ChatGames\ChatGames\ChatGames.Android\bin\Debug\ChatGames.Android.dll
1> No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
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;
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Answers

  • jezhjezh Member, Xamarin Team Xamurai
    edited May 29

    @GaryBerg
    You can try to delete the obj/ bin folders, then restart VS, and rebuild it.

    if the error persist, you can try to turn on MultiDex option.

  • GaryBergGaryBerg USMember ✭✭

    Thanks for the response. I tried both of those. The error still persists.

  • jezhjezh Member, Xamarin Team Xamurai

    @GaryBerg
    You can try to update your Nuget package to the latest .

  • GaryBergGaryBerg USMember ✭✭

    The support and Xamarin Forms nugets are all updated to the latest. 28.0.0.1 for the support, and
    4.0.0.425677 for Xamarin Forms.

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post a basic demo so that we can test with it?

  • GaryBergGaryBerg USMember ✭✭

    I don't know what you would want me to provide. I added no code to the solution. I added no packages. As I said above, I started up a Visual studio 2019 project right from an empty project template "create a mobile app", up the target framework to Android 9.0, compile the android project, then I get this error. Could you try this from your machine and see if you get the error?

  • jezhjezh Member, Xamarin Team Xamurai

    @GaryBerg
    I am so sorry, I couldn't reproduce this problem with the target framework is Android 9.0.

    Could you please post a screenshot of the Intalled Nuget?

  • GaryBergGaryBerg USMember ✭✭

    Sure. Here you go.

  • jezhjezh Member, Xamarin Team Xamurai

    @GaryBerg
    Sorry, I couldn't reproduce this problem .
    Could you please share the project you created which have such question?

  • GaryBergGaryBerg USMember ✭✭

    Ok I attached all the project files. I tried this again from visual studio 2019, created an empty project, did nothing to the proejct as it was set to Android 9.0. Got the error. Then I upgraded the Xamaran nuget. Still go the error.

  • YotayuduYotayudu Member ✭✭

    Could you find the solution?

  • GaryBergGaryBerg USMember ✭✭

    I did not find the solution.

  • YotayuduYotayudu Member ✭✭

    And what did you do?

  • GaryBergGaryBerg USMember ✭✭

    My project is on hold. Does anyone else have a solution?

Sign In or Register to comment.