Sam Stern
Sam Stern

Reputation: 25134

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.

This does not happen with other resource types, and it works in my app when running outside of tests.

Upvotes: 1

Views: 204

Answers (1)

Sam Stern
Sam Stern

Reputation: 25134

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.

Upvotes: 2

Related Questions