-
Notifications
You must be signed in to change notification settings - Fork 219
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
Cannot invoke "com.android.layoutlib.bridge.android.BridgeContext.isAppCompatTheme()" because "this.mContext" is null #630
Comments
By chance, does your test contain other Junit Rules outside of a RuleChain? |
No, our test class only has the single Paparazzi rule |
@jrodbx I'm seeing the same error as part of the work I'm doing around Showkase + Paparazzi integration. I'm now integrating that artifact to airbnb's app and seeing errors of this nature in about 33% of the tests. The test itself uses Error java.lang.NullPointerException: Cannot invoke "com.android.layoutlib.bridge.android.BridgeContext.setBridgeInflater(android.view.BridgeInflater)" because "context" is null
at com.android.layoutlib.bridge.impl.RenderSessionImpl.init(RenderSessionImpl.java:205) |
-- | --
| | at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:168) |
| | at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:116) |
| | at com.google.testing.junit.testparameterinjector.PluggableTestRunner$ContextMethodRule$1.evaluate(PluggableTestRunner.java:420) |
| | at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) |
| | at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) |
| | at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) |
| | at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) |
| | at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) |
| | at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) |
| | at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) |
| | at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) |
| | at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) |
| | at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) |
| | at org.junit.runners.ParentRunner.run(ParentRunner.java:413) Sample Test |
I spent way too long on this, but was eventually able to figure out the line that's causing this issue. Removing this from the setup gets rid of this error. Sounds like a bug somewhere in Paparazzi Paparazzi(
maxPercentDifference = 0.0,
showSystemUi = false,
- renderingMode = SessionParams.RenderingMode.SHRINK
) |
One more update: I was able to reduce the odds of the error happening with my previous comment, however it still happens often enough that I cannot possibly use it without causing disruption. Any chance I could get some advice? |
Just to close the loop on this issue, this happens when a component uses Lottie Compose in its implementation. Thanks to this tip on a separate issue. To get around this, add this to your test class. @Before
fun setup() {
LottieTask.EXECUTOR = Executor(Runnable::run)
} |
Closing as fixed |
I wouldn't really count this as fixed, as this is only a workaround. Error message is still super confusing and unhelpful. |
Yes, it's not fixed. |
@matejdro can you file a new issue with a repro project? It's not a workaround since the issue is ultimately not a Paparazzi issue but rather a Lottie issue, due to how it exposes its threading implementation. |
It only happens on our CI system, I cannot reproduce it on my machine to make a reliable repro project. Maybe "Lottie" section could be added to README to explain this? I am prepared to offer a Pull Request for that. |
I'm seeing this issue on all my paparazzi tests, even without
Is there anything else I can do to avoid this?
For reference, I'm on:
|
I'm seeing this on a project, but not using Lottie |
Description
We are seeing on CI that paparazzi occasionally fails with the error:
Steps to Reproduce
We are using Paparazzi with compose. The test class is in android unit test sources with junit 4.
Sorry, I don't have any better repro steps and can't tell why it only sometimes happens.
Expected behavior
Test should run consistently without crashing
Additional information:
The text was updated successfully, but these errors were encountered: