遇到这个要点后:https ://gist.github.com/chemouna/00b10369eb1d5b00401b ,我注意到它正在使用Google Truth
库:https ://google.github.io/truth/ 。因此,我首先按照以下过程build.gradle
在 Android Studio 中的文件中添加库:
buildscript {
repositories.mavenLocal()
}
dependencies {
testImplementation "com.google.truth:truth:0.40"
}
但是当我想为我的断言 java 类添加 Truth 入口点的静态导入时:
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
我收到符号Truth
无法解析的错误。我尝试重建我的项目并实施此处所述的解决方案:AndroidTestCompile dependencies not recognize in the imports,主要运行以下 gradle 任务:
- ./gradlew 应用程序:依赖项
- 组装AndroidTest
但问题仍然存在。
有什么帮助吗?
我真的应该在我的 build.gradle 文件中添加这些行吗?:
buildscript {
repositories.mavenLocal()
}
如果我已经有了这些:
repositories {
mavenCentral()
jcenter()
google()
}