M
M
MaxLich2017-12-27 10:57:04
Java
MaxLich, 2017-12-27 10:57:04

Why can't I import libraries in IntelliJ using Gradle?

Hello. Registered dependencies in build.gradle:

repositories and dependencies
repositories {

    maven { url "http://repo.maven.apache.org/maven2" }
    mavenCentral()
    mavenLocal()
}
dependencies {
    compile(
            [group: 'com.google.guava', name: 'guava', version: '18.0'],
            [group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
            [group: 'net.java.dev.jna', name: 'jna', version: '4.5.0'],
            [group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'],
            [group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25']
    )
}

On the right, in the opening panel regarding the gradle, all these dependencies are there. On the left, in the project structure - they are not. In the code, everything is underlined in red, when I press "alt + enter", it does not offer to import the required class. Manual import doesn't help either. What to do?
IDE window screenshot
5a4353c639b68301650786.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SergiiSl, 2017-12-28
@MaxLich

there is something with the project structure... the simplest thing is to do File->New->Project from exising sourse and select this project there at the gradle.build level. The project will be rebuilt with the correct structure (now I don't see the source sets on the right, but the dependencies should be in them)
By the way, why so many mavenrepos?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question