TheKingElessar
TheKingElessar

Reputation: 1771

"Cannot resolve symbol" for all classes from external library in Intellij

I have an Intellij project that uses Gradle. I've added an external dependency in the form of a JAR file in the libs folder, and added it to build.gradle using this:

compile fileTree(dir: 'libs', include: '*.jar')

Intellij recognizes it as a dependency, since it allows me to browse the file and view its contents, plus it suggests the packages I can import.

enter image description here enter image description here

However, I can't use any of the classes contained. Intellij says Cannot resolve symbol '[classname]'. This occurs in both the library itself and my project files.

enter image description here enter image description here

Other Gradle dependencies work fine, like those in the form compile "some.group:artifact:version".

I've tried all of the fixes I've found online for this, including:

How can I use this local JAR file as a dependency?

Upvotes: 1

Views: 2699

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 401975

It looks like the jar you've attached contains *.java files instead of the compiled *.class files.

Library dependencies will work only for the jars with the .class files. Find a library jar instead of the source jar for this dependency and place it to the libs directory, reimport the project.

Upvotes: 2

Related Questions