Duplicate Hamcrest and JUnit classes after updating Gradle and Android Studio to 3.5

Well, the solution is always pretty simple, but very strange, I have to exclude junit in the app's build.gradle:

configurations {
    compile.exclude group: "junit", module: "junit"
}

And everything works fine again...


I used the exclude JUnit solution for a while but when I started wanting to actually use JUnit it became a problem. I scoured the gradle docs and found a solution which worked, so sharing it here for anyone who has the same problem but can't just exclude JUnit.

configurations.all {
    resolutionStrategy.dependencySubstitution {
        substitute module('org.hamcrest:hamcrest-core:1.1') with module('junit:junit:4.10')
    }
}