简体   繁体   English

错误:无法在Robolectric中解析配置':app:testCompile`的所有依赖项

[英]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.

相关问题 Android 构建错误:无法解析配置':app:androidJacocoAgent' 的所有依赖项 - Android build error:Could not resolve all dependencies for configuration ':app:androidJacocoAgent' 无法解析配置':app:debugCompileClasspath的所有依赖项 - Could not resolve all dependencies for configuration ':app:debugCompileClasspath 无法解析配置的所有依赖项':app:_debugCompile' - Could not resolve all dependencies for configuration ':app:_debugCompile' 无法解析配置':app:_debugApkCopy'的所有依赖项 - Could not resolve all dependencies for configuration ':app:_debugApkCopy' 无法解析配置 ':app:debugAPKCopy' 的所有依赖项 - could not resolve all dependencies for configuration ':app:debugAPKCopy' 无法解析配置':app:_debugCompile'的所有依赖项。 -Android Studio - Could not resolve all dependencies for configuration ':app:_debugCompile'. -Android Studio android failed 无法解析配置':app:debugRuntimeClasspath'的所有依赖项 - android failed Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath' Gradle 同步失败:无法解析配置“:app:debugRuntimeClasspath”的所有依赖项 - Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath' 无法解析配置':app:_debugCompile'Houndify的所有依赖项 - Could not resolve all dependencies for configuration ':app:_debugCompile' Houndify 无法解析配置 ':app debug Runtime Classpath' 的所有依赖项 - Could not resolve all dependencies for configuration ':app debug Runtime Classpath'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM