Gradle add library to classpath

I am using Gradle for a project. My build.gradle JUnit has a dependency, but every time I import the project again, it does not recognize the JUnit library and asks to add it to the classpath. This issue applies not only to JUnit, but also to other dependencies. Did I add JUnit to the wrong place?

PS: the project builds just fine, it's just an IDE (IntelliJ), which stands for everything red.

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

Error screenshot

+4
source share
1 answer

The dependency statement is correct. You are probably opening the project in IntelliJ IDEA in the wrong way.

I suggest you open the Gradle project as follows:

  • Press File | Openmenu
  • build.gradle

Gradle (. ).

+6

Source: https://habr.com/ru/post/1629009/


All Articles