Search code examples
gradledependenciesupgrade

Trying to upgrade from Gradle 4.10 to 5.0, but am getting unresolved references errors


I'm trying to upgrade to Gradle 5, but am getting "Unresolved reference" errors when compiling - most of which are internal libraries that are within a classpath. Additionally, the javax.inject library somehow doesn't exist anymore.

I've tried individually adding in the libraries that are now missing, but it then fails to build for some reason (with some sort of abstract method error).

buildscript {
...
  dependencies {
    classpath "some-internal-classpath"
  }
}

How do I get it so that Gradle 5 will be able to resolve those references from my internal classpath + have javax.inject again?


Solution

  • When upgrading to Gradle 5.x from Gradle 4.x, there is one change in behaviour that can cause what you observe:

    So the fix is usually to find out the libraries you were using in your code but did not depend upon explicitly.

    A useful method for doing that investigation is to leverage the dependencies task of Gradle, focused on the compileClasspath, effectively running ./gradlew dependencies --configuration compileClasspath with Gradle 4.x and 5.x and analysing the differences.