Skip to content

Error when rendering in Compose Preview #24

@OskarPersson

Description

@OskarPersson

When trying to render any MathView in a Preview, I get an error. My Composable looks like this:

@Composable
private fun _MathView(latex: String, modifier: Modifier = Modifier) {
    val currentTextStyle = LocalTextStyle.current.merge(
        MaterialTheme.colorScheme.onBackground
    )

    // Extract the font size from the current text style
    val currentFontSize = currentTextStyle.fontSize

    AndroidView(
        modifier = modifier,
        factory = { context ->
            MTMathView(context).apply {
                this.latex = latex
                this.fontSize = MTMathView.convertDpToPixel(currentFontSize.value)
                this.textColor = currentTextStyle.color.hashCode()
            }
        },
    )
}

And the error looks like this:

java.lang.UnsatisfiedLinkError: no main in java.library.path: C:\Users\oskar\AppData\Local\Programs\Android Studio 2\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;...
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
	at java.base/java.lang.System.loadLibrary(System.java:1993)
	at com.pvporbit.freetype.FreeType.<clinit>(FreeType.java:210)
	at com.agog.mathdisplay.render.MTFontMathTable.<init>(MTFontMathTable.kt:90)
	at com.agog.mathdisplay.render.MTFont.<init>(MTFont.kt:23)
	at com.agog.mathdisplay.render.MTFont.<init>(MTFont.kt:13)
	at com.agog.mathdisplay.MTFontManager$Companion.fontWithName(MTFontManager.kt:27)
	at com.agog.mathdisplay.MTFontManager$Companion.latinModernFontWithSize(MTFontManager.kt:44)
	at com.agog.mathdisplay.MTFontManager$Companion.defaultFont(MTFontManager.kt:56)
	at com.agog.mathdisplay.MTMathView.<init>(MTMathView.kt:126)
	at com.agog.mathdisplay.MTMathView.<init>(MTMathView.kt:29)
	at com.oskar.hp.android.MathViewKt._MathView$lambda$3$lambda$2(MathView.kt:110)
	at androidx.compose.ui.viewinterop.ViewFactoryHolder.<init>(AndroidView.android.kt:344)
	...
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions