我们有一个使用 flavors 的项目,并希望使用 gradle 1.3 提供的新 com.android.test 插件在单独的项目中进行集成测试。我们已按照说明进行操作 here ,但是当我们尝试同步 gradle 时,我们收到以下错误:
Error:Configuration with name 'MyFlavorDebug-classes' not found.
这是我们测试项目的 build.gradle 文件。我们的应用程序中有匹配的风格。
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
apply plugin: 'com.android.test'
android {
compileSdkVersion 21
buildToolsVersion = '22.0.1'
targetProjectPath ':MyApp'
targetVariant 'MyFlavorDebug'
}
你应该有这样的结构:
root
app
build.gradle
flavor1test
build.gradle
在app/build.gradle
android{
defaultConfig {
applicationId 'com.example.myapp'
}
productFlavors {
flavor1 {
//
}
}
}
在 flavor1test/build.gradle
中是这样的:
apply plugin: 'com.android.test' // A plugin used for test-only-modules
android {
compileSdkVersion 22
buildToolsVersion = '23.0.0rc3'
defaultConfig {
minSdkVersion XX
targetSdkVersion 22
// The package name of the test app
testApplicationId 'com.example.myapp'
// The Instrumentation test runner used to run tests.
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
// Set the target app project.
targetProjectPath ':app'
targetVariant 'flavor1Debug'
}
dependencies {
// Android Testing Support Library's runner and rules and hamcrest matchers
}