Intellij downloads Gradle dependencies but cannot resolve symbols
When I try to use the dependencies I laid out in my build.gradle Intellij fails to build the code and throws errors java: cannot find symbol
. How can I get Intellij to recognize my dependencies?
PS: lbrary shows up in "External Libraries" and I also have this problem with all my other dependencies.
In my build.gradle I have the following:
...
dependencies {
...
compile 'com.squareup.okhttp:okhttp:2.1.0'
}
In my code, I am trying to use this library:
import com.squareup.okhttp.OkHTTPClient;
...
OkHTTPClient client = new OkHTTPClient();
errors raised on both lines.
EDIT from comment: Command line build fails with the same errors, I assume I blamed Intellij wrongly. How can I find out why the dependencies are not loading? They sit in my build.gradle in dependencies as I've shown. They are also present when run gradle dependencies
under compilation, by default, at runtime, testCompile and testRuntime, but not in the archives. Where is the problem?
EDIT2: output from gradle dependencies
:
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Classpath for compiling the main sources.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
default - Configuration for default artifacts.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
runtime - Classpath for running the compiled main classes.
+--- com.google.code.gson:gson:2.3.1
\--- com.squareup.okhttp:okhttp:2.1.0
\--- com.squareup.okio:okio:1.0.1
testCompile - Classpath for compiling the test sources.
+--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp:2.1.0
| \--- com.squareup.okio:okio:1.0.1
\--- junit:junit:4.11
\--- org.hamcrest:hamcrest-core:1.3
testRuntime - Classpath for running the compiled test classes.
+--- com.google.code.gson:gson:2.3.1
+--- com.squareup.okhttp:okhttp:2.1.0
| \--- com.squareup.okio:okio:1.0.1
\--- junit:junit:4.11
\--- org.hamcrest:hamcrest-core:1.3
BUILD SUCCESSFUL
Total time: 1.82 secs
source to share
No one has answered this question yet
Check out similar questions: