Android 测试模块(Gradle 插件 1.3):来自非默认 Maven 存储库的依赖项

Android Test Module (Gradle Plugin 1.3): dependencies from non-default maven repositories

我正在尝试 APK Tests in Modules 并完成了整个设置过程。如果从 jCenter 以外的存储库中获取 Gradle 应用程序 模块的依赖项,则 Gradle 会遇到问题。

依赖项之一是 MPAndroidChart 使用 jitpack 定位:

repositories {
    maven { url "https://jitpack.io" }
}

但是 plugin: 'com.android.test' 似乎忽略了这个子句:它不是从 app 模块传播的。

报错:

Error:A problem occurred configuring project ':test'.
> Could not resolve all dependencies for configuration ':test:_debugCompile'.
   > Could not find com.github.PhilJay:MPAndroidChart:v2.0.9.
     Searched in the following locations:
         https://jcenter.bintray.com/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.pom
         https://jcenter.bintray.com/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.jar
         file:/Users/me/Library/Android/sdk/extras/android/m2repository/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.pom
         file:/Users/me/Library/Android/sdk/extras/android/m2repository/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.jar
         file:/Users/me/Library/Android/sdk/extras/google/m2repository/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.pom
         file:/Users/me/Library/Android/sdk/extras/google/m2repository/com/github/PhilJay/MPAndroidChart/v2.0.9/MPAndroidChart-v2.0.9.jar
     Required by:
         company-android-app:test:unspecified > company-android-app:app:unspecified

看起来问题可以通过将存储库显式添加到 test 模块来省略:

repositories {
    maven { url "https://jitpack.io" }
    mavenCentral()
}

使用 buildToolsVersion '23.0.0rc3'classpath 'com.android.tools.build:gradle:1.3.0'

进行了测试