Not A Subscriber?
Join thousands of people who build and refuse to get left behind. One message a week on building, using AI as an accelerator, and staying sharp in the new AI frontier.
Receive one free message a weekJanuary 13, 2015 Donn Felker
Android Studio Espresso 2.0 ClassNotFoundException
File this under “I’m writing this so when I Google for it in 6 months, it pops up”.
I recently set up an existing Android project with Espresso 2.0 and immediately stared running into this error when I ran the tests:
Running testsTest running startedTest running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'Empty test suite.I spent some time last night fighting this error and then I figured out the solution this morning.
The problem is that I’m using Dagger in this project and Espresso 2.0 also uses Dagger (see Espresso Dependencies). The core problem is that the ‘javax.inject’ dependency was borking the test run.
How to to Fix
Change this
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0')to this:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') { exclude group: 'javax.inject'}Problem solved.