[英]Resources$NotFoundException google_play_services_version after gradle and robolectric upgrade
I am attempting to update a project to Gradle 3.0.1 / gradle wrapper 4.1. 我正在尝试将项目更新为Gradle 3.0.1 / gradle wrapper 4.1。 Robolectric tests that used to work are now failing when run with ./gradlew testDebugUnitTest
: 当使用./gradlew testDebugUnitTest
运行时,过去工作的Robolectric测试现在失败了:
android.content.res.Resources$NotFoundException: org.odk.collect.android:integer/google_play_services_version
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:72)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:220)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:108)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:35)
This is an open source project -- the updated configuration is available here . 这是一个开源项目 - 此处提供了更新的配置。
It doesn't seem related but just in case -- we also started seeing pmd
and lint
errors that we didn't before. 它似乎没有关联,但为了以防万一 - 我们也开始看到我们之前没有的pmd
和lint
错误。 Those configs or versions haven't changed. 那些配置或版本没有改变。
I have found the following possibly related issues: 我发现了以下可能相关的问题:
None of the suggestions on those posts have helped so far. 到目前为止,关于这些职位的任何建议都没有帮助。 I've read the release notes for gradle and robolectric and am not seeing any hints. 我已经阅读了gradle和robolectric的发行说明,但没有看到任何提示。 Any idea which tool is likely to be causing the problem? 知道哪个工具可能导致问题? Any thing else I can try? 还有什么别的我可以试试吗?
Removing a @Config(constants = BuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml", packageName = "org.odk.collect")
and adding in testOptions.unitTests.includeAndroidResources true
did the trick. 删除@Config(constants = BuildConfig.class, sdk = 21, manifest = "src/main/AndroidManifest.xml", packageName = "org.odk.collect")
并在testOptions.unitTests.includeAndroidResources true
添加testOptions.unitTests.includeAndroidResources true
就可以了。 Full diff here . 完全差异在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.