For my instrumentation tests I was using
@RunWith(AndroidJUnit4.class)
from
import androidx.test.runner.AndroidJUnit4;
I tried all given above until I went to the official Android site, and they suggested importing from androidx.test.ext.junit.runners.AndroidJUnit4 instead of androidx.test.runner.AndroidJUnit4. link
androidx.test.ext.junit.runners.AndroidJUnit4
androidx.test.runner.AndroidJUnit4