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

时间:2015-08-13 09:55:02

标签: android android-gradle android-testing

我正在尝试APK Tests in Modules并完成整个设置过程。如果它们从jCenter以外的存储库中获取,那么Gradle在查找 app 模块的依赖关系时会遇到问题。

其中一个依赖项是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

1 个答案:

答案 0 :(得分:0)

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

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

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

进行测试