title: Configuring gradle to use JUnit, Mockito, Hamcrest and Espresso
body: <p>I have an Android project that uses Mockito, Hamcrest and Espresso to help with testing.</p>
  
  <p>No matter what I try with the Gradle build file, I get a <code>NoSuchMethodError</code> for <code>org.hamcrest.Matcher.anyOf</code> when I try to run my tests after doing <code>gradle androidTestCompile</code>.</p>
  
  <p>Here is my current configuration:</p>
  
  <pre><code>dependencies {
      compile project(':GameCore')
      androidTestCompile files(
              'libs/espresso-1.1.jar',
              'libs/testrunner-1.1.jar',
              'libs/testrunner-runtime-1.1.jar'
      )
      androidTestCompile(
              'junit:junit:4.11',
              'org.mockito:mockito-core:1.10.0',
              'com.google.guava:guava:14.0.1',
              'com.squareup.dagger:dagger:1.1.0',
              'com.google.dexmaker:dexmaker:1.0',
              'com.google.dexmaker:dexmaker-mockito:1.0',
              'org.hamcrest:hamcrest-core:1.3',
              'org.hamcrest:hamcrest-library:1.3'
              )
  </code></pre>
  
  <p>I've tried rewriting the Mockito and JUnit requirements to exclude Hamcrest like so:</p>
  
  <pre><code>androidTestCompile('junit:junit:4.11') {
      exclude group: 'org.hamcrest'
  }
  </code></pre>
  
  <p>But this doesn't make any difference.</p>
  
  <p>The <code>GameCore</code> project is a pure Java project. It also has dependencies on JUnit and Mockito, but as they're specified as <code>testCompile</code>, I don't think they should be interfering.</p>
  
  <p>The output for <code>gradle dependencies</code> for this module for 'androidTestCompile` is:</p>
  
  <pre><code>+--- junit:junit:4.11                                                               
  |    \--- org.hamcrest:hamcrest-core:1.3
  +--- org.mockito:mockito-core:1.10.0
  |    +--- org.hamcrest:hamcrest-core:1.1 -&gt; 1.3
  |    \--- org.objenesis:objenesis:2.1
  +--- com.google.guava:guava:14.0.1
  +--- com.squareup.dagger:dagger:1.1.0
  |    \--- javax.inject:javax.inject:1
  +--- com.google.dexmaker:dexmaker:1.0
  +--- com.google.dexmaker:dexmaker-mockito:1.0
  |    +--- com.google.dexmaker:dexmaker:1.0
  |    \--- org.mockito:mockito-core:1.9.5 -&gt; 1.10.0 (*)
  +--- org.hamcrest:hamcrest-core:1.3
  \--- org.hamcrest:hamcrest-library:1.3
       \--- org.hamcrest:hamcrest-core:1.3
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Having further investigated the problem, I see that espresso needs Hamcrest 1.1, but I'm also using assertThat, which is in Hamcrest 1.3. Hamcrest 1.3 doesn't have the anyOf method that espresso uses. So I guess I'm stuck :)</p>