alfietap
alfietap

Reputation: 2273

Jetpack Compose vector parsing issue

I'm trying to load a vector but keep getting this error stack trace

 java.lang.IllegalArgumentException: Unknown command for: R
    at androidx.compose.ui.graphics.vector.PathNodeKt.toPathNodes(PathNode.kt:275)
    at androidx.compose.ui.graphics.vector.PathParser.addNode(PathParser.kt:525)
    at androidx.compose.ui.graphics.vector.PathParser.parsePathString(PathParser.kt:84)
    at androidx.compose.ui.graphics.vector.VectorKt.addPathNodes(Vector.kt:72)
    at androidx.compose.ui.graphics.vector.compat.XmlVectorParser_androidKt.parsePath(XmlVectorParser.android.kt:279)
    at androidx.compose.ui.graphics.vector.compat.XmlVectorParser_androidKt.parseCurrentVectorNode(XmlVectorParser.android.kt:101)
    at androidx.compose.ui.res.VectorResources_androidKt.loadVectorResourceInner(VectorResources.android.kt:81)
    at androidx.compose.ui.res.VectorResources_androidKt.vectorResource(VectorResources.android.kt:62)
    at androidx.compose.ui.res.VectorResources_androidKt.vectorResource(VectorResources.android.kt:52)
    at com.tapmax.football.ui.screens.design.DesignScreenKt$KitPager$1.invoke(DesignScreen.kt:440)
    at com.tapmax.football.ui.screens.design.DesignScreenKt$KitPager$1.invoke(DesignScreen.kt:439)

I couldnt copy in the full code of my vector so i've attached an image, its just a normal vector

enter image description here

Upvotes: 12

Views: 2291

Answers (1)

helios
helios

Reputation: 13841

Your compiler warnings might complain about a RESOURCE_TOO_LONG (some path value). It seems there's a maximum for those.

The parser opens the string value, finds the R and doesn't know what to do with it.

You can either:

  • simplify the XML (or the source material you used to generate it).
  • split that path into two paths (probably adding a Z IIRC at the end of the first path to close it, and a M<last_coordinate> to the second to start from where it left). But really it'd be better to have a compliant source to start with :)

Upvotes: 4

Related Questions