我尝试将Android Support Instrumentation测试添加到我的应用程序中,但我遇到了这个问题:无法解析符号'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 filder中)
请帮忙! Apoth
我发现了问题。我使用各种构建类型,我只需要将testBuildType "debug_uat"
添加到我的build.gradle。