Error creating Vector Image Asset: <text> is not supported - android

I created a basic SVG file in illustrator using Line Tool, Eclipse Tool & Text only. The font I used was Century Schoolbook.
When I try to configure a vector asset I get the error, is not supported. The preview shows the SVG without the text
Am I not suppose to use text on SVG files? Surely that can't be the case?
Here's the error:

At present, Android's vector assets handle a small subset of SVG, mostly focused on paths. It does not appear that it supports text.
However, your SVG tool may have the ability to export an SVG where the text (in your desired font) is converted to paths. This also ensures that your text shows up in your desired (converted) font, as the font you might be using in your artwork may not exist on the Android device.

Related

When i use .svg file "ERROR #<image> is not supported" in Android Studio

I want to create a Splash screen for my android application for this purpose i create ".svg" file by using three different ".png" images using Adobe XD. bust when i import ".svg" file through vector Asset it only show background of ".svg" image it does not show other images which i used to create this file for splash screen. I also used this http://inloop.github.io/svg2android/ to get proper ".xml" file and past it in drawable folder but still no change. I am attaching images of my error this is where error is shown
when i click on error foe more detail i I found this error
I want to use my app logo for splash screen "Please Help" me an tell me how to use logo on splash screen i just started android development.
Thankyou.
The Android Studio SVG importer only supports a subset of SVG. Remember that it is converting the SVG to a VectorDrawable. So only things that work in a VectorDrawable can be imported from the SVG. Basically that means you must stick to just the vector shapes - rectangles, ellipses, paths etc
See: Which SVG elements are supported by Android studio and which are not?
If your SVG only contains PNG images, then there is no point in using an SVG anyway. Just import your PNGs to your project and use an ImageView to display them.
If you really need to display an SVG. Then use a library that properly supports SVGs. Such as my one: AndroidSVG.

Android Studio does not import all parts of an SVG Vector

I want to import some vector graphics from illustrator for the design of my android studio app. If I export my vector graphics as SVG, this works wonderfully. All parts of my project are successfully exported and the result is satisfactory (image 1). However, when I create this SVG file as a new Vector Asset in Android Studio, one of my blue circles is suddenly missing (see image 2). What can be the reasons why Android studio does not import all parts of my SVG? Or could the reason be a wrong export from illustrator?
Edit: Added Picture 3 to show what happens if I use a online converter instead. The output is even worse.
Any Help is appreciated!
Picture 1:
Picture 2:
Image 3...Result when I use a online converter to get a xml vector(also wrong)*
The version of the SVG that is displayed in the converter window is rendered by a built-in SVG renderer in Android Studio. It's a preview of the SVG. It does not necessarily reflect what the output of the converter will be.
So the bug you are seeing is with the built-in SVG renderer.
VectorDrawables don't really support gradient fills. At least the converter doesn't support them. So even if the displayed SVG were perfect, the generated VectorDrawable won't include the gradient circles anyway.
So you have a few alternative approaches:
Change your circles to solid fill and then convert to VectorDrawables.
Like #1, but add gradients by using predefined gradient definitions.
Use an actual SVG rendering library (like AndroidSVG) in your app.
Switch to using a bitmap background (ie PNG)
Draw the background yourself using Canvas methods.
Personally, I would go with #3.
Android Studio doesn't convert complex graphics into vector drawable. It only converts flat icons. You have to use a png here dude !!

ic_launcher_foreground not fitting

I'm trying to make my new app compatible with the latest Android requirements, which means including an SVG version of my app icon. I was successful at converting my PNG icon to SVG, and I was able to include the resulting path in the ic_launcher_foreground.xml, but when previewing the result in the ic_launcher.xml or ic_launcher_round.xml the SVG is either too big, or not in the right position.
Normally one would apply scaling or transformation to fix that. Inkscape does this, and leaves the actual path values alone. But the android file format does not seem to support scaling or transforming.
How do I make an SVG path fit the 108x108 (or better 72x72 center) as required by Android? It should be possible to use any freely available SVG icon and make it fit, right?

Vector Asset Studio exception parsing xml

I have an svg file (vector graphics) which opens fine in Internet Explorer, but fails when opening in Vector Asset studio (part of android studio) with:
For input string: 2.85465in Exception while parsing XML file:
I think this is caused by the decimal point, where a comma is expected as the computer used has Dutch settings and "," is expected to be the decimal separator.
Where does Vector asset studio gets it's information for this and can it be changed locally?
With this error in Vector Asset:
Could not generate a preview
Exception while parsing XML file:
Premature end of file.
My provisional solution was:
Before getting the .svg file, I generated a .png with Photoshop CC.
I converted my .png to .svg with a converter
Verify that my .svg can be converted to VectorDrawable. This is to know if the Android Studio Vector Asset will be able to perform the conversion.
And finally, I select the VectorDrawable XML that I generated when I checked and paste a resource into the drawable directory, or I use New-> Vector Asset to generate this resource from my verified .svg.
With check I mean make sure the .svg will be parsed to xml with Vector Asset.
So I observed this error occurs when the image has tiny text and when using the .svg converter is likely to skip it.
SVG files are just text files, you can open them in any text editor (like notepad) and change their content as you like.
Try removeing the in or replace it by px. Asset Studio doesn't seem to work with any other size declaration than px.
There was a conversation on google groups, I think, that I recently read. Took the solution from there. Will add the link if I find it again.
// edit: found it: https://code.google.com/p/android/issues/detail?id=189654

How do I export Android XML vector drawables to another format?

I want to recreate my app for iOS and the icons in Android are XML vectors with the "android:pathData" attribute. How do I convert these to an image that I can place into Xcode and use (preserving transparency)?
I have searched for a solution and found nothing and read the article on the Android Developer site on Vector Asset Studio but found nothing about exporting these drawables to something I can import into Xcode.
I did it by creating an SVG file and copying the value of the pathData attribute of the path element in the XML file and pasting it into the d attribute of the path element in the SVG file. I then converted it to PNG using ImageMagick.
So
<path android:pathData="[Path Data]">
becomes
<path d="[Path Data]">.
Then
convert -background none image.svg image.png
in the command line.
If there is a better way of doing this please post it.
After using the trick Questioner provide, I use a browser to open the svg file, zoom-in to the size as big as possible and take a screenshot. FYI.

Categories

Resources