我试图将 Android Support Instrumentation 测试添加到我的应用程序中,但我遇到了这个问题:Cannot resolve symbol 'AndroidJUnit4'
好像我没有包裹android.support.test.runner
我的应用程序的 build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "---PACKAGENAME---"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file("../keys/debug.jks")
storePassword "*"
keyAlias "debug"
keyPassword "*"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug_uat {
debuggable true
signingConfig signingConfigs.debug
}
debug_int {
debuggable true
signingConfig signingConfigs.debug
}
staging {
debuggable false
signingConfig signingConfigs.debug
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(path: ':volley')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
}
gradle 同步和构建没问题,但我无法将支持 AndroidJUnitRunner 添加到我的运行配置和我的 android 测试类(该类在 androidTest 文件中)
请帮忙!阿波特
更新
我发现了问题。我使用各种构建类型,我只需要添加testBuildType "debug_uat"
到我的 build.gradle。