未找到Gradle DSL方法:testCompile() [英] Gradle DSL Method not found: testCompile()

查看:263
本文介绍了未找到Gradle DSL方法:testCompile()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个项目,并且已经达到了一个阶段,如果没有单元测试,继续进行下去是不明智的.我以为可以在Android Studio中进行单元测试,但是我无法运行测试.

Hi I am working on a project and have reached a stage where it would be unwise to continue without unit testing. I thought unit testing in Android Studio would be straight forward but I can't run my tests.

这是我的依赖项.一切正常,直到我添加了最后一行代码.然后,我会收到标题中的错误消息.

Here are my dependencies. Everything works fine until I add the last line of code. I then receive the error message that is in the title.

如何解决此问题并运行测试?

How do I fix this and run my tests?

这是我正在关注的教程: http://tools.android .com/tech-docs/unit-testing-support

Here was the tutorial I was following: http://tools.android.com/tech-docs/unit-testing-support

推荐答案

Android插件从1.1版开始引入了官方的单元测试支持.这意味着testCompile配置在以前的版本中不可用.根据您的评论,您正在使用Android Gradle插件版本1.0.0.这就是为什么您的构建抱怨缺少testCompile配置.

Official Unit testing support was introduced in Android plugin starting from version 1.1. This means that testCompile configuration is not available on previous versions. Based on your comment, you are using Android Gradle plugin version 1.0.0. That's why your build complains about missing testCompile configuration.

截止到今天,最新发布的Android Gradle插件版本为1.3.0,所以我建议尽快升级到该版本.

As of today, the latest released Android Gradle plugin version is 1.3.0, so I would suggest moving to this version ASAP.

您需要做的-在根级别build.gradle文件中将com.android.tools.build:gradle版本更新为1.3.0:

What you need to do - is in root level build.gradle file update com.android.tools.build:gradle version to 1.3.0:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}

这篇关于未找到Gradle DSL方法:testCompile()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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