Skip to content

IntelliJ, Java and Gradle troubleshooting tips

Michael Hulse edited this page Apr 3, 2020 · 4 revisions

General wonkiness

If something feels wonky in IntelliJ, do this:

  1. Navigate to File > Invalidate Caches / Restart…
  2. If this is a Gradle project, wait for the above to complete, then open the Gradle tab and click the “Reimport All Gradle Projects” button: image

Unsupported class file major version XX

If you see:

Unsupported class file major version 57

… or:

BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 57

  1. Follow instructions above “General Wonkiness
  2. Delete the ~/.gradle/caches directory
  3. Run gradle clean in your project
  4. Open IntelliJ and start up your project

Downgrading Java

If you see:

$ gradle clean
Starting a Gradle Daemon (subsequent builds will be faster)
e: /Users/mhulse/…/settings.gradle.kts:3:18: Unresolved reference: BuildConfig
FAILURE: Build failed with an exception.
* Where:
Settings file '/Users/mhulse/…/settings.gradle.kts' line: 3
* What went wrong:
Script compilation error:
  Line 3:               maven { setUrl(BuildConfig.badgrMavenRepoUrl) }
                           ^ Unresolved reference: BuildConfig
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org

Try downgrading to a lesser Java version:

  1. Install a Java version manager, like sdkman: Java sdkman maven gradle (and spring boot)
  2. Check your current Java version: $ java -version
  3. Run $ sdk list java and then $ sdk install java 12.0.2-open
  4. Open IntelliJ project and set SDK path: File > Project Structure… and remove existing SDK versions; add a new one by click the + button (/Users/mhulse/.sdkman/candidates/java/12.0.2-open is the path I used in this example):
  5. In the same window as the previous step, click on the project tab and “Project SDK” to 12:
Clone this wiki locally