Android Studio : Cannot resolve symbol “Truth” (Truth library)
遇到以下要点后:https://gist.github.com/chemouna/00b10369eb1d5b00401b,我注意到它正在使用
1 2 3 4 5 6 7 | buildscript { repositories.mavenLocal() } dependencies { testImplementation"com.google.truth:truth:0.40" } |
但是,当我想为我的断言java类的Truth入口点添加静态导入时:
1 2 | import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; |
我收到符号
我试图重建我的项目并实现此处所述的解决方案:导入中未识别的AndroidTestCompile依赖项,主要运行以下gradle任务:
- ./gradlew应用程序:依赖项
- 组装AndroidTest
但问题仍然存在。
有什么帮助吗?
我是否应该在build.gradle文件中实际添加这些行? :
1 2 3 | buildscript { repositories.mavenLocal() } |
如果我已经有这些:
1 2 3 4 5 | repositories { mavenCentral() jcenter() google() } |
To use the Java 8 extensions, also include
com.google.truth.extensions:truth-java8-extension:0.40.
注意
您应该致电
1 | androidTestImplementation"com.google.truth:truth::0.40" |
读取