gpt4 book ai didi

android - 使用 Gradle Android 构建系统指定测试依赖项

转载 作者:IT老高 更新时间:2023-10-28 22:02:15 30 4
gpt4 key购买 nike

我想在阅读 Gradle Dependency Management Basics 之后为我的测试指定依赖项我虽然可以像这样将 testCompile 调用添加到我的依赖项声明中:

dependencies {
compile group: 'com.squareup.dagger', name: 'dagger', version: '1.0.0'


testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'com.squareup', name: 'fest-android', version: '1.0.1'
}

但是,这会失败并显示以下错误消息:

> Could not find method testCompile() for arguments [{group=junit, name=junit, version=4.11}] on project ':simstatus'.

我错过了什么吗?

( Full gradle build file for reference )

最佳答案

android 构建系统不使用标准的 Gradle Java 插件。

Its documentation说:

As mentioned previously, next to the main sourceSet is the androidTest sourceSet, located by default in src/androidTest/

Additionally, the sourceSet can be configured to have its own dependencies. By default, the application and its own dependencies are added to the test app classpath, but this can be extended with

dependencies {
androidTestCompile 'com.google.guava:guava:11.0.2'
}

更新

As of May 2017 Doc, testCompile is deprecated and you should use testImplementation

dependencies {
androidTestImplementation 'com.google.guava:guava:11.0.2'
}

关于android - 使用 Gradle Android 构建系统指定测试依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16637608/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com