question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] SVG rendered as text instead of image

See original GitHub issue

I’m trying to render a remote SVG. I’m on 2.0.6, Android 12 and Chrome is on version 91.0.4472.114.

Here is the snippet I’m using:

<Image
    source={{ uri: 'https://s3.amazonaws.com/cdn.titanvest.com/misc/car-hex.svg' }}
    style={{ width: 100, height: 100 }} //needs the size
/>

Even using inlined svg doesn’t work:

<Image
    source={{
        uri: `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"  viewBox="0 0 100 100">
        <ellipse data-custom-shape="ellipse" cx="50" cy="50" rx="50" ry="50" fill="green"  stroke="#00FF00" stroke-width ="2" />
        </svg>`,
    }}
    style={{ width: 300, height: 300 }}

All I get is this: Screenshot 2022-02-03 at 15 32 40

The same piece of code works perfectly on iOS.

How can I fix it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
seekshivacommented, Feb 24, 2022

Version 2.0.7 released with the changes.

0reactions
AlbertoMeQcommented, Feb 23, 2022

@seekshiva Thanks for merging the PR. Do you know when it will be added to npm? So I can update the version on my side 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why text attribute in SVG file does not appear in Android ...
I think the text attribute is somehow not interpreted by Android Studio. I was able to solve the problem by converting the text...
Read more >
Add multi-density vector graphics - Android Developers
Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and ...
Read more >
text-rendering - SVG: Scalable Vector Graphics | MDN
The text-rendering attribute provides hints to the renderer about what tradeoffs to make when rendering text.
Read more >
flutter_svg | Flutter Package - Pub.dev
Draw SVG (and some Android VectorDrawable (XML)) files on a Flutter Widget. Getting Started #. This is a Dart-native rendering library. Issues/PRs will...
Read more >
Option to display SVG as "raw text" instead of image - Atlassian
This is due to a "broken image" icon being displayed for certain SVG files that have been pushed to the remote repo and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found