-
Notifications
You must be signed in to change notification settings - Fork 10
IntelliJ, Java and Gradle troubleshooting tips
Michael Hulse edited this page Apr 3, 2020
·
4 revisions
If something feels wonky in IntelliJ, do this:
- Navigate to File > Invalidate Caches / Restart…
- 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:
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
- Follow instructions above “General Wonkiness”
- Delete the
~/.gradle/caches
directory - Run
gradle clean
in your project - Open IntelliJ and start up your project
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:
- Install a Java version manager, like sdkman: Java sdkman maven gradle (and spring boot)
- Check your current Java version:
$ java -version
- Run
$ sdk list java
and then$ sdk install java 12.0.2-open
- 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): - In the same window as the previous step, click on the project tab and “Project SDK” to
12
: