Ihor Kostenko Ihor Kostenko - 1 year ago 148
Android Question

NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor() in jUnit tests for Android

I try to write test and I want to use guava 19.0 for project, but Android Studio built guava 17.0 I force it in build.gradle

configurations.all {
resolutionStrategy.force 'com.google.guava:guava:19.0'

And it works, but how to do the same for test? Because when run test it uses old guava 17.0

Answer Source

You need to analyze your dependencies for conflicts. You have at least two dependencies in your test score that depend on Guava but specify different versions.

You can use gradle dependencies and gradle dependencyInsight to find which of your dependencies depend on specific versions of Guava. Once you find the culprit (the one(s) depending on the version(s) you don't want) you can then exclude them.

See https://docs.gradle.org/current/userguide/dependency_management.html for more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download