Adz Adz - 1 year ago 303
Android Question

Android Espresso testing 'Cannot resolve symbol 'InstrumentationRegistry''

I'm trying to import


my build.gradle file

androidTestCompile ''
androidTestCompile ''
androidTestCompile ''
androidTestCompile ''

in default config:

defaultConfig {
testInstrumentationRunner ""

Is there a library I'm missing here? I'm trying to import InstrumentationRegistry but it doesn't recognise it!

Tim Tim
Answer Source

Check what kind of test do you use.

InstrumentationRegistry used for Instrumented tests that use emulator or device and they are placed in src/androidTest and use config androidTestCompile.
If you use Local unit tests for JVM from folder src/test you should use config testCompile

testCompile ''

After that you can import InstrumentationRegistry, but you will get other errors at run-time.

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