Skip to content

Gradle project builds successfully but IntelliJ cannot resolve references

Every usage of the following Kotlin library compiles and can be used, but IntelliJ’s autocomplete (and perhaps others) cannot resolve the references.

I am using it as a dependency via JitPack:
JDK 11, Gradle 6.3 (wrapper)

The gradle project builds fine but just autocompletion is broken. Other dependencies like kotlinx.coroutines work fine.

IntelliJ's linter error

It altv-kotlin is a fatjar and even includes the sources in the jar:
It in turn uses a java dependency, so altv-kotlin uses some Java and the end fatjar includes both Kotlin and Java sources if that makes a difference.

Could it be that the source are not being put in the JAR correctly for some reason? I couldn’t even get IDEA to decompile the references for autocompletion. I have a strong feeling this is an issue tied to altv-kotlin library specifically, and not any of my environment setup.

I’ve tried to delete the .idea folder, Invalidate Caches / Restart, update Kotlin plugin for both IDEA and gradle projects and even updated IDEA from 2018 to 2020 with no avail whatsoever. I tried these answers as well but did not solve the problem:
I also noticed the warning about Kotlin Runtime being bundled with the library, but even without it being bundled in it IDEA complains.



So, locally I seem to have resolved the issue by recreating the project and copying the sources into there. Seems to have worked, why I don’t know.
However, when using the remote dependency from JitPack, because I was including all the classfiles in the JAR to have it be a fatjar.

jar {
    from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it)

Ever since I removed that line from the jar task, IntelliJ IDEA was able to resolve the references normally.

8 People found this is helpful