Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Espresso testing 'Cannot resolve symbol 'InstrumentationRegistry''

Tags:

I'm trying to import

 import android.support.test.InstrumentationRegistry; 

my build.gradle file

androidTestCompile 'com.android.support.test:testing-support-lib:0.1' androidTestCompile 'com.android.support.test:runner:0.2' androidTestCompile 'com.android.support.test:rules:0.2' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 

in default config:

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

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

like image 740
Adz Avatar asked Mar 28 '16 12:03

Adz


1 Answers

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

testImplementation 'com.android.support.test:runner:1.0.2' 

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

like image 187
Tim Avatar answered Sep 19 '22 16:09

Tim