Explain Codes LogoExplain Codes Logo

Unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

java
java-8
gradle
android-studio
Alex KataevbyAlex Kataev·Dec 26, 2024
TLDR

The error suggests a JDK mismatch. Wires crossed somewhere! Update your project's JDK version to get things back on track.

For Maven, tweak the pom.xml:

<properties> <!-- Rocking out our JDK version --> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>

For Gradle, adjust build.gradle:

// Plug and play your JDK version sourceCompatibility = '1.8' targetCompatibility = '1.8'

Replace '1.8' with your project's JDK version.

Next stop: updating your IDE to the party vibe of JDK11. It can't handle these funky new attributes from its older self. Suit up!

Whistle while you work! It's all about harmonizing your environment:

  • Update your toolset: Ensure your Android Studio is running on JDK11 or later. Like well-aged cheese, it just gets better!
  • Gradle needs to mingle: Set Gradle's JDK to version 11 within your project settings. It likes to keep up with the cool kids.
  • Where to find JDK 11: You can download from Oracle's site or OpenJDK.
  • Set the mood: In Android Studio, navigate to Project Structure and update your JDK version. Time for a refresh!
  • Dance it out: After the update, let Android Studio take a breather with the "Invalidate Caches / Restart" boogie.

Dodging Disco Disasters: Potential obstacles

New includes a side of unexpected fun. Here's what you should watch out for:

  • Lambda expressions jazz: Your code might need a few tweaks to match the rhythm of JDK 11.
  • Unified groove: Keep everyone in sync! Developers should use matching JDK versions to avoid stepping on toes.
  • Trace their steps: Find the class causing issues in the stack trace for any spoilsport causing the TaskExecutionException.

Get on the dance floor with Android S and beyond

With Android S (API Level 31) and beyond, it's time to get groovy with JDK 11. It's not just about avoiding errors; it's about unlocking features for your smooth moves.

Here's your footwork:

  • Set the stage: Your compileSdkVersion should be 31 or later. Curtain's about to go up!
  • Work out the kinks: If the KaptDebugKotlin task fails, it's a sign that you need to switch your dance routine.
  • Take a bow: Your Gradle builds should be error-free and ready for their standing ovation after updating JDK.

Reset the dance floor: Clearing caches

Updating JDK sounds simple but sometimes, our old dance shoes don't want to retire easily.

  • Invalidate Caches / Restart: Taking two steps back helps us move several steps forward. Found under the File menu, this option clears the stale dance floor and refreshes Android Studio.
  • New Steps, New Path: Ensure Android Studio is following you to the correct updated JDK path.
  • Sync the rhythm: Trigger a Gradle sync to let everyone know it's time for the new dance routine.