Hello! I am trying to render a SVG like that ``` Image(painter = painterResource(id = R.drawable.svg...
v
Hello! I am trying to render a SVG like that
Copy code
Image(painter = painterResource(id = R.drawable.svg_name), contentDescription = "")
and I get the following error:
java.lang.IllegalArgumentException: Unknown command for: R
Is there some sort of limitation? Is there any way to overcome this issue?
s
No this should work just fine, example. Most likely you’ve not imported R at all or you’re using
android.nonTransitiveRClass=true
and you’re not referencing it correctly. Or something like that, but this code should work otherwise.
v
It does not have to do with R file... It seems that it can not parse the .xml :(
Maybe there are some unsupported tags or size limit... 🤔
s
I don’t think it’d say
java.lang.IllegalArgumentException: Unknown command for: R
in this case. Could you then try and add another drawable from the built-in vector drawables in Android Studio and test if that works instead?
m
Are you using an actual SVG file? Android doesn't directly support SVG to my knowledge. You have to use android studio (or some other tool) to convert it to an android vector drawable.
v
@Stylianos Gakis other drawables work fine. Most of them are icons. This is a full screen illustration. That's why I asked about the size
@mattinger it is an SVG that was imported in android studio (with the corresponding tool). So this SVG was converted to drawable
e
what is in the drawable? it sounds like there's a
R
in the pathData, but that's not a valid command for VectorDrawable or SVG
v
It is an illustration... Yeah... there is a n R in the pathData.... Is there any way to overcome this?
e
take it out
v
probably there is an issue... As i found this 😞
e
R isn't defined as a path command in SVG, user agents are supposed to only render the part of a path before an invalid command. https://www.w3.org/TR/SVG/paths.html I don't know what your design tool is intending to emit but it's not supported
965 Views