2

This seemingly very simple or even silly question has been bothering me.

What I did:

  1. On my fresh new Mac OS X 10.13.6

  2. I used Intellij CE 2018.1 version to check out a repo from Github.

  3. Whenever I tried to run unit tests in this repo from my Intellij, it simply says: "Cannot find symbol", screenshot below: enter image description here

  4. I didn't make any changes locally, this is a build green project that I checked out from a git repo.

  5. this is build.gradle file

    apply plugin: 'java' apply plugin: 'checkstyle' group = 'com.fishercoder' version = '1.0-SNAPSHOT' checkstyle { //include ( '**/*.java') configFile = file("${rootDir}/fishercoder_checkstyle.xml") } description = """""" sourceCompatibility = 1.9 targetCompatibility = 1.9 repositories { mavenCentral() maven { url "http://repo.maven.apache.org/maven2" } } dependencies { compile 'com.google.code.gson:gson:2.8.0' testCompile group: 'junit', name: 'junit', version:'4.12' } 

What I've tried:

  1. Interestingly, I could print out a "Hello world" in src code part, but tst part just don't compile in Intellij.
  2. I've invalidated caches and restart my Intelij, no luck.
  3. I've removed the folder on my disk, completely shutdown my Intellij, redo git clone into my disk first, then open Intellij to import it, see below: enter image description here

Then imported it as a gradle project, see below: enter image description here

Left everything on the following page as default: enter image description here

Then in my Intellij console, I got this error: enter image description here Any help is appreciated!

5
  • Did you import the project as a gradle project in IDEA? Commented Sep 6, 2018 at 2:31
  • 1
    Open Gradle Tool window and refresh the project (hit the circular button at the top). Commented Sep 6, 2018 at 2:50
  • @abdul Yes, I've tried that, no luck. Commented Sep 6, 2018 at 3:01
  • @SazzadurRahaman Thanks for reminding me that. I just did it and I'll update my original post. Commented Sep 6, 2018 at 3:07
  • @SazzadurRahaman updated, thanks! Commented Sep 6, 2018 at 3:13

2 Answers 2

1

Looks like when you are importing the project, Gradle wrapper is choosing an incompatible version of Gradle for JDK 10 (See This).

You can try installing gradle manually in your system (preferably any version that is greater than 4.7). Then choose the option "Use local gradle distribution" and specify the gradle installation path in Intellij.

Then you should be fine!

Sign up to request clarification or add additional context in comments.

1 Comment

I just ran a gradle --version, it says Gradle 4.8.1
1

It is not Intellij specific issue of choosing Gradle version. This is as mentioned a Gradle bug when Gradle can not determine Java version for the 10 JDK. It is fixed in Gradle version >=4.7.

The Gradle error is thrown when IDE tries to run Gradle using the Java 10 JDK. Please use Gradle version >=4.7 in File | Settings | Build, Execution, Deployment | Build Tools | Gradle -> Use local gradle distribution option. Or use 1.8 JDK for the Gradle JVM.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.