Android Test Module (Gradle Plugin 1.3) doesn't work: "debug-classes not found"

I'm attempting to set up a unit test module as described in the android studio blog post. However, doing a gradle build fails telling me "Configuration with name 'debug-classes' not found". Debug is the name of the targetVariant it's trying to build, but I don't understand what is going wrong here.

Here's my test module's gradle file.

apply plugin: 'com.android.test'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

targetProjectPath ':app'
targetVariant 'debug'
}    

This is the blogpost describing the new test module functionality. http://android-developers.blogspot.com/2015/07/get-your-hands-on-android-studio-13.html

I'm using the Gradle plugin v1.3.0

Answers


I was also curious about separating app code and test code and i had hard time to figure it out. I look at the stack trace and found the DependencyManager (line 238) having a TODO to fix that in gradle.

1) You are right about the build flavors.You have to enter the correct variant

targetVariant '<flavor>Debug'

e.g.

targetVariant 'flavor1Debug'

2) You also need to change you targetProjectPath's module build.gradle. Add the following snippet:

android {

    // ...

    publishNonDefault true

    // ...

}

which publishes all build variants! It its disabled by default due to some limitations of gradle.


Here is a sample app that works https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint

You must use

buildToolsVersion = '23.0.0rc3'

And of course

publishNonDefault true

Need Your Help

iOS get physical screen size programmatically?

iphone ios ipad screen screen-size

Is this possible? I want the number of inches, not the number of pixels. I know it is approximately 160 ppi. But not exactly.

Bootstrap visible and hidden classes not working properly

html css twitter-bootstrap responsive-design

I tried to use the Bootstrap visible and hidden classes to create content only visible on mobile/desktop. I noticed the classes weren't working properly (and I have noticed a lot of people had this