jxs1211 / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

Espresso2.0 (bundled with guava) - NoSuchMethodError while initializing Espresso #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Built my test apk
2.Tried to run on Android L(Nexus 5) - device
3.Part of my code calling 
'android.support.test.espresso.Espresso.registerIdlingResources'

What is the expected output?
Espresso test should run normally.

What do you see instead?
Test failed while initializing espresso class saying 'no such method error'

What version of the product are you using? On what operating system?
espresso.2.0[bundled with dependencies guava, dagger .. ] with hamcrest 1.3
Am using ANT build.

Please provide any additional information below.

After successful build/installation of my test apk in device. 

part of the log:

Caused by: java.lang.NoSuchMethodError: No static method 
anyOf([Lorg/hamcrest/Matcher;)Lorg/hamcrest/Matcher; in class 
Lorg/hamcrest/Matchers; or its super classes (declaration of 
'org.hamcrest.Matchers' appears in /data/app/com.foo.bar.test-2/base.apk)

I have verified my dex having Matchers.anyof(Matcher[]) method. Also verified 
there is no proguard running on test project build.

Is harcrest & espresso versions are incompatible?

Original issue reported on code.google.com by mahendra...@impigertech.com on 22 Jan 2015 at 2:09

GoogleCodeExporter commented 9 years ago
Hey, thanks for posting this. I believe I have it figured out:

Test Runner:

    android {
        ...
        defaultConfig {
            ...
            testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        }
    }

Dependencies:

   dependencies {
        // Hamcrest - kept at 1.1, 1.3 is latest
        androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
        androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
        androidTestCompile 'org.hamcrest:hamcrest-library:1.1'

        androidTestCompile ('com.android.support.test:testing-support-lib:0.1') {
            exclude module: 'hamcrest-core'
        }
        androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
            exclude module: 'hamcrest-core'
        }
        androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
        androidTestCompile('junit:junit-dep:4.10') {
            exclude module: 'hamcrest-core'
        }
    }

Let me know if this has helped you!

Original comment by jaredsburrows@gmail.com on 2 Feb 2015 at 5:20

GoogleCodeExporter commented 9 years ago
Espresso uses 1.1, so if you were including 1.3, the method signature might 
have changed. We will, eventually, upgrade to 1.3 (unfortunately, it's a 
breaking API update).

Original comment by vale...@google.com on 18 Mar 2015 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by vale...@google.com on 18 Mar 2015 at 5:52