3

We have a project which is using flavors and want to use the new com.android.test plugin available with gradle 1.3 to have our integration tests in a separate project. We've followed the instructions here, but when we try to sync gradle we get the following error:

Error:Configuration with name 'MyFlavorDebug-classes' not found.

Here is our test project's build.gradle file. We have a matching flavor in our app.

buildscript {

    repositories {
        mavenCentral()
        jcenter()
    }

}

apply plugin: 'com.android.test'


android {

    compileSdkVersion 21
    buildToolsVersion = '22.0.1'
    targetProjectPath ':MyApp'
    targetVariant 'MyFlavorDebug'
}
Jake Hall
  • 1,963
  • 22
  • 24

1 Answers1

2

You should have a structure like this:

root
 app 
   build.gradle
 flavor1test
   build.gradle

In app/build.gradle

   android{
       defaultConfig {
           applicationId 'com.example.myapp'

       }
       productFlavors {
            flavor1 {
               //   
            }
       }
    }

In flavor1test/build.gradle something like:

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
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841