MAUI .NET 8 iOS - Method not found: SkiaSharp.SKMatrix SkiaSharp.SKMatrix.MakeTranslation(single,single)

Aneetha 65 Reputation points
2024-07-27T10:06:34.74+00:00

I have created a new MAUI .NET 8 project and migrated the Xamarin forms project code.

I am facing an exception as below when loading the SVG image,

Unhandled Exception:

System.MissingMethodException: Method not found: SkiaSharp.SKMatrix SkiaSharp.SKMatrix.MakeTranslation(single,single)

at SkiaSharp.Extended.Svg.SKSvg.LoadElements(IEnumerable`1 elements, SKCanvas canvas, SKPaint stroke, SKPaint fill)

at SkiaSharp.Extended.Svg.SKSvg.Load(XDocument xdoc)

at SkiaSharp.Extended.Svg.SKSvg.Load(XmlReader reader)

at SkiaSharp.Extended.Svg.SKSvg.Load(Stream stream)

at SKM_MOBILE.UI.Core.Utils.CommonUtils.GetSVG(String svgName, Boolean isEnergized, Boolean inService, String imagePath)

at SkiaSharp.Views.Maui.Controls.SKCanvasView.OnPaintSurface(SKPaintSurfaceEventArgs e)

at SkiaSharp.Views.Maui.Controls.SKCanvasView.SkiaSharp.Views.Maui.ISKCanvasView.OnPaintSurface(SKPaintSurfaceEventArgs e)

at SkiaSharp.Views.Maui.Handlers.SKCanvasViewHandler.OnPaintSurface(Object sender, SKPaintSurfaceEventArgs e)

at SkiaSharp.Views.iOS.SKCanvasView.OnPaintSurface(SKPaintSurfaceEventArgs e)

at SkiaSharp.Views.iOS.SKCanvasView.Draw(CGRect rect)

at UIKit.UIApplication.UIApplicationMain(Int32 args, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58

at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94

at SKM_MOBILE.Program.Main(String[] args) in /Users/macmini3/Documents/MAUI/SKM_MOBILE/SKM_MOBILE/Platforms/iOS/Program.cs:line 13

This is my code,

svg.Load(stream); throws this exception.

using (var stream = GetImageStream(svgName.Replace(".PNG", ".svg").Replace(".png", ".svg"), imagePath))
{
    if (stream != null)
    {
        svg = new SkiaSharp.Extended.Svg.SKSvg();
        svg.Load(stream);
        SVGComponentImage[$"{key}"] = svg;
    }
}

How do I resolve this issue?

Developer technologies | .NET | .NET MAUI
{count} votes

1 answer

Sort by: Most helpful
  1. Matthew Leibowitz 1 Reputation point Microsoft Employee
    2024-08-08T17:11:23.99+00:00

    The SkiaSharp.Extended.Svg library is very old and does not support any new SkiaSharp versions. It is highly likely that is will not work.

    This library was very minimal, so it was not worth keeping when there was a vastly superior library that does basically all you can ever want with SVG: https://github.com/wieslawsoltes/Svg.Skia

    Please use Svg.Skia instead.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.