I am running Android Instrumentation tests and when I use the Context
returned by InstrumentationRegistry.getContext()
to retrieve a string given an id I get the message:
android.content.res.Resources$NotFoundException: String resource ID #0x7f060020
I've tried ids from other string resources but to no avail.
I've looked through several questions about this same exception on stackoverflow but all of them involve passing an the string id to View.setText
. This is not relevant for me since I am creating a library and there are no View
s at all.
You can use targetContext like in this example:
InstrumentationRegistry.getTargetContext().getString(R.id.name);
This should fetch your string resouces
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With