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.

Error loading svg [Android Only]

See original GitHub issue

Description

Getting System.NullReferenceException when trying to load svg images.

Steps to Reproduce

Put some svg files on an XAML page. I’m using this way:

<ff:SvgCachedImage
         Grid.Column="0"
         Source="{Binding Image}"
         VerticalOptions="Center"
         Aspect="AspectFit"
         HeightRequest="24"/>

The Image binding is a string like “image.svg” and the svg file is located on Resources/drawable folder on Android Project and have the BuildAction: AndroidResource

Expected Behavior

Image shown correctly

Actual Behavior

Error on console app:

Image loading failed: back.svg;(size=0x30,dip=True,type=SvgDataResolver)
System.NullReferenceException: Object reference not set to an instance of an object.
  at FFImageLoading.Svg.Platform.SvgDataResolver.Decode (SkiaSharp.SKPicture picture, SkiaSharp.SKBitmap bitmap, FFImageLoading.Work.DataResolverResult resolvedData) [0x0000a] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SvgDataResolver.cs:84 
  at FFImageLoading.Svg.Platform.SvgDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x005ef] in C:\projects\ffimageloading\source\FFImageLoading.Svg.Shared\SvgDataResolver.cs:307 
  at FFImageLoading.DataResolvers.WrappedDataResolver.Resolve (System.String identifier, FFImageLoading.Work.TaskParameter parameters, System.Threading.CancellationToken token) [0x00044] in C:\projects\ffimageloading\source\FFImageLoading.Common\DataResolvers\WrappedDataResolver.cs:21 
  at FFImageLoading.Work.ImageLoaderTask`3[TDecoderContainer,TImageContainer,TImageView].RunAsync () [0x00300] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:556 

Basic Information

  • Version with issue: 2.4.6.929 (all Nugets)
  • Xamarin.Forms Version: 3.6.0.344457
  • Android compile target: Android 9.0 (Pie)
  • Android version target: Android 9.0 (Pie)
  • Last known good version: 2.4.4.859
  • Platform: Android 9.0 - Emulator

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
daniel-luberdacommented, May 2, 2019

Could you confirm that 2.4.7.938 prerelease nuget fixes the issue?

0reactions
kubaizicommented, Oct 31, 2020

2.4.7.938 fixes the problem, but can’t use pinch and pan in this release, is there a common ground?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my SVG failing to load in Vector Asset Studio
The SVG below is failing to open in Android Studio's Vector Asset Studio in resulting in the error: "Empty preview image! EXCEPTION in...
Read more >
Cannot load .svg files using the Android app : r/LaserDock
I just save the files to Android folder 'Download' and import them with LaserOS. Which error message do you receive and are you...
Read more >
please, do you know how to import svgs using vector ...
Android doesn't implement it all, because otherwise it would just support SVG. If you want to support complex SVG, you should either use...
Read more >
Add multi-density vector graphics | Android Studio
If you want to use vector drawables only, you can use Android ... Vector Asset Studio also lets you import your own SVG...
Read more >
bug in loading SVG images on mobile devices
when i'm loading the images to a gallery, it works fine only on browser (chrome), but not on Mobile (Android). images3.png.
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