Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be
import android.support.test.runn
Short Story Version:
Upgrade your Gradle to the latest Version
I am answering this question post on Feb, 15th, 2020. Unfortunately, I have exhausted every possible solutions mentioned here and elsewhere.
https://github.com/codepath/android_guides/wiki/UI-Testing-with-Espresso
https://github.com/udacity/AdvancedAndroid_TeaTime/issues/14
Android Espresso : cannot resolve symbol AndroidJUnit4.class
Cannot resolve symbol AndroidJUnit4
Android Espresso : cannot resolve symbol AndroidJUnit4.class
Yes, none of them above workes. I use the built-in function, "Migrate to Andoridx", it may remind me that I have to upgrade my target SDK versions and my gradle version. After I upgraded my gradle version from 2.0.2 to 3.5.3. They just works, even the old import statement works.