2015-05-05 41 views
2

我们有三个BuildVariants:release,debugdevelop。第一种是默认值AndroidStudio。最后一个是我们的内部测试。下面是CONFIGS:(没有什么不同比Signing Configenter image description here enter image description hereAndroid测试支持库未找到Espresso和不同的BuildVariants

我们有进口我们build.gradle如下:

dependencies { 
    // App dependencies 
    compile 'com.android.support:support-annotations:22.0.0' 
    compile 'com.google.guava:guava:18.0' 
    // Testing-only dependencies 
    androidTestCompile 'com.android.support.test:runner:0.2' 
    androidTestCompile 'com.android.support.test:rules:0.2' 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1' 
} 

现在,我们已经创建了androidTest/文件夹(其中Espresso-测试位于)。我看的例子从Android-Testing Samples in GitHub.

但AndoridStudio总是说“找不到Symbole”为AndroidJUnit4.class: enter image description here

(而现在,很多的解释后 - 对不起为:d) 我发现了这个问题。我们的构建变体设置为Android Instrumented Tests(这没问题),但App-Module位于developBuildVariant。当我们将其更改为debug时,一切都很好。

现在我不确定这是一个错误还是这是正常的?!因为我们没有什么不同 - 而不是Singing Config(但我已经测试过它,这不是问题) - 在BuildVariants上。而当这是正常的,为什么?!

编辑:

我已经创建了一个AOSP客票太:https://code.google.com/p/android/issues/detail?id=172029

回答

2

请参阅我的错误更新。总之,你需要这条线:

android { 
    testBuildType "develop" 
} 
+0

位这只是一个解决方法或?在未来的版本中,可能没有这条线?! – StefMa

+0

显然,这不仅仅发生在自定义构建变体上,而且还发生在库的默认构建类型中。换句话说,我也只是在试图在测试实用程序库中使用这些类时展现出相同的行为。即使在强制testBuildType在库的Gradle脚本中“调试”之后,AS的行为就像它没有被声明一样。 –

+0

@DiegoTori请在b.android.com上提供所有详细信息(或上面链接的评论) –