[英]Error : Could not resolve all dependencies for configuration ':app:testCompile` in Robolectric
Hi I am writing unit test cases of my demo android application, so for this I am using robolectric
unit framework. 嗨,我正在编写我的演示android应用程序的单元测试用例,为此,我正在使用
robolectric
单元框架。 When I run it gradlew test
then it gives error Could not resolve all dependencies for configuration ':app:testCompile`. 当我运行
gradlew test
它给出错误无法解析配置':app:testCompile`的所有依赖项。 Please see attached screenshot. 请参阅附件的屏幕截图。
Below is my root build.gradle 以下是我的root build.gradle
build.gradle 的build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
My project build.grade file looks like below 我的项目build.grade文件如下所示
apply plugin: 'android'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.xyz.robolectricapplication"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
// this sets the root test folder to src/test overriding the default src/instrumentTest
instrumentTest.setRoot('src/test')
}
}
apply plugin: 'android-test'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
testCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'junit:junit:4.10'
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
}
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
Error Logs 错误记录
Project Structure looks like below 项目结构如下
Thanks in advance. 提前致谢。
If you're going to grab the snapshot, you need to grab the 2.4-SNAPSHOT. 如果要获取快照,则需要获取2.4-SNAPSHOT。
See: https://github.com/robolectric/robolectric/blob/master/pom.xml 参见: https : //github.com/robolectric/robolectric/blob/master/pom.xml
So replace testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
with testCompile 'org.robolectric:robolectric:2.4-SNAPSHOT'
因此,将
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
替换为testCompile 'org.robolectric:robolectric:2.4-SNAPSHOT'
Or probably better to grab the stable 2.3 release: org.robolectric:robolectric:2.3
或可能会更好地获取稳定的2.3版本:
org.robolectric:robolectric:2.3
There is a sample gradle project here, it might be helpful: https://github.com/robolectric/deckard-gradle 这里有一个示例gradle项目,可能会有所帮助: https : //github.com/robolectric/deckard-gradle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.