-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE when calling context.createConfigurationContext(configuration) #2909
Comments
I'm not sure what the issue is here. I added a test in the above PR and it passes. What configuration are you passing in. Can you share the code from MyApplication / LocaleHelper? I've also removed ShadowConfiguration in the PR as I think we can just use real framework code, the shadow looked pretty incomplete and would have become out dated as new config options are added in newer SDKs, this might just magically fix your issue. You can try this by creating your own custom shadow for config and making it have an empty class body with no @implements methods. |
Hi @jongerrish,
You can check it here: https://github.com/AndrazP/npe-shadow-configuration How can I override the current implementation of ShadowConfiguration? |
@AndrazP Can you test with Robolectric 3.3 please. We've basically removed all the implentation of ShadowConfiguration so it should be using Framework code (we left it there to give users a migration path without breaking their builds). I wrote a test to verify your behavior so it looks like it would be fixed:- robolectric/robolectric/src/test/java/org/robolectric/shadows/ShadowContextTest.java Line 44 in cf2244e
Please reopen if this doesn't work on 3.3. for you. |
It works. Thank you! |
@jongerrish Im still having this issue even after I updated to Robolectric 3.3.2 somehow the Configuration is still calling ShadowConfiguration. Test configuration: Bellow I post my stacktrace. Any ideas?
|
Seeing the same stacktrace unless I use @config(sdk = N) |
Fixes: #2909 PiperOrigin-RevId: 191613613
9d2e978 by @brettchabot fixed my issue. Had to use the snapshot version https://github.com/robolectric/robolectric#using-snapshots |
@jongerrish, |
@tamaralu If your issue in receiving of localized string you simply have to annotate a method with @config(qualifiers="en"). |
Description
Steps to Reproduce
Robolectric & Android Version
Robolectric 3.2.2, Android 23
The text was updated successfully, but these errors were encountered: