Android studio 机器人分子3.0-rc2 Hamcrest核心冲突

Android studio 机器人分子3.0-rc2 Hamcrest核心冲突,android-studio,robolectric,android-actionbaractivity,Android Studio,Robolectric,Android Actionbaractivity,您好,我正在尝试运行ActionBar活动单元测试,我正在使用Robolectirc-RC2,但当我尝试同步我的android studio时,我收到以下错误/警告。 警告:与依赖关系冲突org.hamcrest:hamcrest-core。应用程序和测试应用程序的解析版本不同。 你知道怎么解决吗 repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } mavenLocal()

您好,我正在尝试运行
ActionBar
活动单元测试,我正在使用
Robolectirc-RC2
,但当我尝试同步我的android studio时,我收到以下错误/警告。 警告:与依赖关系冲突
org.hamcrest:hamcrest-core
。应用程序和测试应用程序的解析版本不同。 你知道怎么解决吗

repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenLocal()
mavenCentral()
}


以下是我们如何在项目中指定
roblectric

   testCompile("org.robolectric:robolectric:${robolectricVer}") {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

好的,解决方案是添加以下代码

configurations.all {
resolutionStrategy {
    force 'org.hamcrest:hamcrest-core:1.3'
}}
然后根据 仅用于1.x版和2.x版:

机器人分子应用

对于3.x版:

RuntimeEnvironment.application

另外替换

Config(emulateSdk=18,reportSdk=18,manifest=“src/test/AndroidManifest.xml”)


@Config(sdk=18)

尝试将
unitTestCompile
更改为
testCompile
,现在我发现以下错误。与依赖项“com.android.support:支持注释”冲突。应用程序和测试应用程序的解析版本有所不同。此外,我需要使用robolectric进行测试,而不是默认的android测试。请阅读我关于依赖范围的评论。我已经做了上述更改,现在android studio找不到junit jar文件,我遇到了一些错误。错误:包org.roblectric.annotation不存在导入org.roblectric.annotation.Config;如果您共享整个build.gradle文件和项目结构,这将很容易。我尝试使用resolutionStrategy,但没有成功(相同的错误,不同的LIB)。我只需在添加相关依赖项的上方添加compile'org.hamcrest:hamcrest core:1.3'就可以让它进行编译——在本例中,是Robolectric。就我而言,这是为了sendgrid
configurations.all {
resolutionStrategy {
    force 'org.hamcrest:hamcrest-core:1.3'
}}