Unresolved reference ActivityTestRule for AndroidX
I found out from this documentation page that class ActivityTestRule stays under androidx.test.rule in AndroidX. In order to import the package, I simply added:
androidTestImplementation 'androidx.test:rules:1.2.0'
to my gradle.
To sum up my gradle now contains:
// Espresso
// Core library
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
The class is under package: androidx.test.ext.junit.rules;
So obviously the most important dependency is:
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
I am wondering why the other answer is uplifted so much, but it doesn't work for me at all.
Hope this helps others like me.