I'm facing an issue with SVG files. I am trying to convert an svg file, which is transferred from Android material library resource(see below) to bitmap. I use this library to do this: https://github.com/bigfishcat/svg-android
.
Sag file I added is called ic_accessibility_black_24dp and it's added by going New->Vector Asset->Material Icon->Choose from Android studio. This is standard SVG, not edited in any way. Here is its xml:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,2c1.1,0 2,0.9 2,2s-0.9,2 -2,2 -2,-0.9 -2,-2 0.9,-2 2,-2zM21,9h-6v13h-2v-6h-2v6L9,22L9,9L3,9L3,7h18v2z"/>
Method I use to convert is as follows:
private Bitmap getBitmapFromSvg(int svgResId){
SVG svgIcon = new SVGBuilder().readFromResource(getResources(), svgResId).build();
Drawable pictureDrawable = svgIcon.getDrawable();
return Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(), pictureDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
}
The exception is on the first line of the method, where I am trying to get SVG file.
08-17 22:14:35.795 31286-31286/com.shearwater.patientportal E/SVGAndroid: Failed to parse SVG.
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: not well-formed (invalid token)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
at com.larvalabs.svgandroid.SVGParser.parse(SVGParser.java:79)
at com.larvalabs.svgandroid.SVGBuilder.build(SVGBuilder.java:187)
at
I don't even know how to go about this, I tried googling, looked and this post, but, can't seem to be able to find a solution. Please, could anyone point me to the right direction?