I had this problem because I was trying to set up a multiplatform library configurations.
I had deleted all the source sets with their dependencies from the "build.gradle" file but kept the "common" source set.
Native was working fine but the JVM was not able to build and showed your error.
In the end, the solution was to not delete the Source set of the JVM neither it's dependencies