Xamarin android: unrecognized Attribute name MODULE

Lars Vinberg 6 Reputation points
2021-06-25T20:14:19.653+00:00

I get this compile error in my Xamarin Android project.
It used to build a week ago. I upgraded VS2019 from 16.9.6 to 16.10.2 since, maybe that changed something?

java.lang.AssertionError: annotationType() :  unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)  collusive.app.Android           
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,362 questions
{count} vote

5 answers

Sort by: Most helpful
  1. Lucas Brahm 21 Reputation points
    2021-07-01T21:18:00.927+00:00

    I'm facing this same issue when trying to compile Xamarin Android with Target Framework Android 11.0.99 (S). Changing to Android 11.0 (R) works fine.

    VS version: 16.10.2

    4 people found this answer helpful.

  2. Jonathan Peppers 16 Reputation points Microsoft Employee
    2021-09-08T20:05:44.13+00:00

    Yes, we've found the above issue is due to the android.jar from API 31 containing Java 9 class attributes inside.

    Same issue occurs with Android Studio projects.

    The recommended solution is to use JDK 11, we have a Microsoft distribution here: https://learn.microsoft.com/java/openjdk/download

    The only dilemma is that the Android designer doesn't support JDK 11 yet. So you may want to stick with API 30, if you use the designer.

    We hope to address the issues here in a future Visual Studio 2022 release.

    1 person found this answer helpful.

  3. Christian Regli 26 Reputation points
    2022-05-06T17:34:42.3+00:00

    Switch to Visual Studio 2022 fixed it in my case.

    1 person found this answer helpful.

  4. grebulon 6 Reputation points
    2021-07-19T10:57:54.213+00:00

    I have the same problem. It is related to compiling for Android 12 (uses-sdk android:targetSdkVersion="31")
    Clean and rebuild didn't help.
    Perhaps upgrading the JDK to 11 will fix this but I haven't tried it yet.

    0 comments No comments

  5. Punnam, Anil 1 Reputation point
    2022-10-07T16:50:40.24+00:00

    Switching to Visual Studio 2022 worked for me too...Thanks for suggesting that..

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.