简体   繁体   English

Resources $ NotFoundException带Robolectric的字符串数组

[英]Resources$NotFoundException for String array with Robolectric

In my Robolectric tests when calling getResources().getStringArray(R.array.some_array_id) I get a crash with Resources$NotFoundException . 在我的Robolectric测试中,当调用getResources().getStringArray(R.array.some_array_id)Resources$NotFoundException导致崩溃。

This does not happen with other resource types, and it works in my app when running outside of tests. 其他资源类型则不会发生这种情况,并且在测试以外运行时可以在我的应用程序中运行。

The problem was how I had defined the array in resources, I used: 问题是我如何使用资源定义数组:

<array name="some_array_id">
</array>

I needed to use: 我需要使用:

<string-array name="some_array_id">
</string-array>

Either one works fine with the real Android SDK but only string-array works with Robolectric. 哪一种都可以在真正的Android SDK上正常运行,但是只有string-array可以与Robolectric一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有Robolectric和风味的Resources $ NotFoundException - Resources$NotFoundException with Robolectric and Flavors Robolectric中的资源NotFoundException - Resources NotFoundException in Robolectric Robolectric:Resources$NotFoundException:带有 Android Gradle 插件 3 的字符串资源 ID - Robolectric: Resources$NotFoundException: String resource ID with Android Gradle Plugin 3 测试中的Gradle Robolectric资源NotFoundException - Gradle Robolectric Resources NotFoundException in Testing Robolectric Resources $ NotFoundException与getBoolean()和getInteger() - Robolectric Resources$NotFoundException with getBoolean() and getInteger() 使用带有Gradle的Robolectric时的资源$ NotFoundException - Resources$NotFoundException when using Robolectric with Gradle 用robolectric运行单元测试get Resources $ NotFoundException - Run unit test with robolectric get Resources$NotFoundException 调用Robolectric.buildActivity()时出现Resources $ NotFoundException - Resources$NotFoundException when calling Robolectric.buildActivity() Robolectric Resources$NotFoundException 找不到库 (aar) 资源 - Robolectric Resources$NotFoundException can't find library (aar) resources Android Studio - Robolectric:android.content.res.Resources $ NotFoundException:没有这样的标签com.my.app:string/app_name - Android Studio - Robolectric: android.content.res.Resources$NotFoundException: no such label com.my.app:string/app_name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM