build.Gradle文件修改如下:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
*androidTestImplementation 'androidx.test:runner:1.2.0'*
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
*androidTestImplementation 'com.android.support.test:rules:1.0.2'*
}
修改了build.Gradle文件后,需要在文件菜单里选择Sync Project with Gradle file
注:如果 ActivityTestRule 找不到, 则需要import androidx.test.rule.ActivityTestRule;如果不能import说明build.Gradle文件少了语句