Layoutlib Bridge initialization failed
See original GitHub issueDescription I was not able to use the Paparazzi in my projects. I’m always getting the same error, it seems like Paparazzi is crashing during the rendering of my Composables. I’ve tried different types of combinations changing CompileSDK and lib version, but I’m always getting the same error.
Steps to Reproduce
Using compose version 1.1.1 and testing a simple button.
class PaparazziLinkButtonTest {
@get:Rule
val paparazzi = Paparazzi()
@Test
fun TestingSnap() {
paparazzi.snapshot(name = "simpleLinkButton") {
LinkButton(
text = "Testing Paparazzi",
onClick = {}
)
}
}
}
It fails when I try to run the test with the message SEVERE: broken: Layoutlib Bridge initialization failed
Additional information:
- Paparazzi Version: 1.0.0
- OS: OS: MacOS 12.4.0
- Compile SDK: 31
- Gradle Version: 7.3.3
- Android Gradle Plugin Version: 7.2.1
- Compose version: 1.1.1
Log
Jul 06, 2022 4:00:48 PM app.cash.paparazzi.internal.PaparazziLogger error
SEVERE: broken: Layoutlib Bridge initialization failed
com.android.layoutlib.common.util.ReflectionUtils$ReflectionException: java.lang.reflect.InvocationTargetException
at com.android.layoutlib.common.util.ReflectionUtils.invoke(ReflectionUtils.java:84)
at com.android.layoutlib.common.util.ReflectionUtils.invokeStatic(ReflectionUtils.java:92)
at com.android.layoutlib.bridge.Bridge.init(Bridge.java:239)
at app.cash.paparazzi.internal.Renderer.prepare(Renderer.kt:84)
at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:158)
at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:122)
at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
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)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.android.layoutlib.common.util.ReflectionUtils.invoke(ReflectionUtils.java:80)
... 41 more
Caused by: java.lang.NoSuchMethodError: 'java.lang.String android.text.TextUtils.join(java.lang.CharSequence, java.lang.Object[])'
at android.graphics.fonts.FontVariationAxis.toFontVariationSettings(FontVariationAxis.java:190)
at android.graphics.FontListParser.readFont(FontListParser.java:269)
at android.graphics.FontListParser.readFamily(FontListParser.java:191)
at android.graphics.FontListParser.readFamilies(FontListParser.java:143)
at android.graphics.FontListParser.parse(FontListParser.java:118)
at android.graphics.fonts.SystemFonts.getSystemFontConfigInternal_Original(SystemFonts.java:244)
at android.graphics.fonts.SystemFonts_Delegate.getSystemFontConfigInternal(SystemFonts_Delegate.java:65)
at android.graphics.fonts.SystemFonts.getSystemFontConfigInternal(SystemFonts.java:244)
at android.graphics.fonts.SystemFonts.getSystemPreinstalledFontConfig(SystemFonts.java:230)
at android.graphics.Typeface.deferredStaticInitializer(Typeface.java:1395)
... 46 more
Failed to init Bridge.
java.lang.IllegalStateException: Failed to init Bridge.
at app.cash.paparazzi.internal.Renderer.prepare(Renderer.kt:83)
at app.cash.paparazzi.Paparazzi.prepare(Paparazzi.kt:158)
at app.cash.paparazzi.Paparazzi$apply$statement$1.evaluate(Paparazzi.kt:122)
at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
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)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Issue Analytics
- State:
- Created a year ago
- Comments:22
Top Results From Across the Web
Failed to load the LayoutLib: com.android.layoutlib.bridge ...
layoutlib.bridge.Bridge " All projects are running fine but i can't see the graphical layout of my .XML files. How can I fix it?...
Read more >core/jni/LayoutlibLoader.cpp - platform/frameworks/base
the Java and native parts of layoutlib, including registering native methods. * This is mostly achieved by copying the way it is done...
Read more >Android Studio: XML Design can't render the ... - Issue Tracker
NoClassDefFoundError: Could not initialize class ... at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321) ... i got this error.
Read more >How to resolve this case " has no instantiable subtypes"-eclipse
How to resolve this error: ClassCastException: com.android.layoutlib.bridge. ... Using rest assured & eclipse :Error occurred during initialization of boot ...
Read more >Android – Failed to load the LayoutLib - iTecNote
Android – Failed to load the LayoutLib: com.android.layoutlib.bridge.Bridge. android. My ADT(Android Developer Tools ) was working fine and it was showing ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the compileSdk 32 issue, you can backport Paparazzi to use earlier platform versions in snapshot tests, like so:
Yep I’m stumped, it’s not a minimal reproducible project but here is my setup: https://github.com/AdamMc331/TOA/pull/146