Inside the build.gradle file there you find the defaultConfig section. With the testInstrumentationRunner attribute the respective test runner can be specified. There the test runner from the android.support package might be specified:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
this has to be change to the test runner from the androidx package:
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"