Android的工作室(摇篮)无法找到的Mockito [英] Android Studio (Gradle) cannot find Mockito

查看:2413
本文介绍了Android的工作室(摇篮)无法找到的Mockito的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用从的Moc​​kito的Andr​​oid 1.2.2工作室内,但我得到了以下错误:

I try to use Mockito from within Android Studio 1.2.2 but I get the following error:

错误:(50,17)无法解析:org.mockito:的Mockito芯:19年1月10日

Error:(50, 17) Failed to resolve: org.mockito:mockito-core:1.10.19

当我手动添加的依赖后同步摇篮出现的错误。这是我的模块摇篮文件的依赖性:

The error occurs when I sync Gradle after adding the dependency manually. This is the dependency in my module Gradle file:

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    testCompile 'org.mockito:mockito-core:1.10.19' 
}

谁能帮我解决这个问题?

Could anyone help my resolve this issue?

相关问题:


  1. 请我首先需要手动下载的Mockito?

  2. 如果是这样,我应该在哪里放呢?

注:评论是有帮助的,以解决上述问题。然而,让我到了我所没能解决的另一个问题。但更新到Android 1.3工作室解决它。我现在在Android Studio中运行的Mockito。

Note: the comments were helpfull to solve the above problem. However, it got me into another problem which I could not solve. But updating to Android Studio 1.3 solved it. I am now running Mockito from within Android Studio.

推荐答案

试着用 androidTestCompile 替换 testCompile ,它导入库的Mockito时为我工作。

Try replacing testCompile with androidTestCompile, it works for me when importing Mockito libs.

不过,您可能会遇到一个运行时错误,如果你只包含的Mockito核心。你需要添加到您的gradle:

However, you may run to a runtime error if you include only mockito-core. You'll need to add into your gradle:

androidTestCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"

如果您有误差dexcache,把此行到您的设置()(假设你正在使用 InstrumentalTestCase

If you have error with dexcache, put this line into your setUp() (Assuming you are using InstrumentalTestCase)

System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());

这篇关于Android的工作室(摇篮)无法找到的Mockito的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆