Reputation: 3723
When I run my Android instrument test, Espresso class initialization fails with the following stacktrace:
java.lang.NoSuchMethodError: No interface method get()Ljava/lang/Object; in class Ljavax/inject/Provider; or its super classes (declaration of 'javax.inject.Provider' appears in /data/app/com.myapp.mock.debug-2/base.apk)
at android.support.test.espresso.DaggerBaseLayerComponent.idlingResourceRegistry(DaggerBaseLayerComponent.java:101)
at android.support.test.espresso.Espresso.<clinit>(Espresso.java:52)
...
I don't know if it is relevant, but my project uses Kotlin.
Any idea?
Upvotes: 2
Views: 996
Reputation: 3723
The solution is to add the following in the proguard file of the application:
-keep class javax.inject.* { *; }
Otherwise the get()
method is removed by Proguard.
Upvotes: 3
Reputation: 74
I think you are using DI in your project. Refer Donn Felker blog,
http://www.donnfelker.com/android-studio-espresso-2-0-classnotfoundexception/
Hope this helps you.
Upvotes: 0