Led Machine
Led Machine

Reputation: 7552

System.MissingMethodException: Default constructor not found for type SkiaSharp.Views.Forms.SKCanvasView?

I am trying to Use Skiasharp on Android, and I get this exception, what could be the reason?

Code:

<skia:SKCanvasView x:Name="canvasView"
               PaintSurface="canvasView_PaintSurface"
               EnableTouchEvents="true" 
               VerticalOptions="FillAndExpand"
               Touch="OnTouch"/>

On C# file

private void canvasView_PaintSurface(object sender,SKPaintSurfaceEventArgs args)
        {
            SKSurface sKSurface = args.Surface;
            SKCanvas canvas = sKSurface.Canvas;
            canvas.Clear(SKColors.White);
            drawPerformerPlatforms.setCanvas(canvas);
            scoreViewerField.runFrame();
        }

Upvotes: 0

Views: 3053

Answers (2)

dsakpal
dsakpal

Reputation: 126

Setting linking to None is a workaround and not a real solution. The problem in your case is that Linker removing the references to Skia classes. You need to preserve the Skia library during the linking process. Please refer to the following article for more information.

https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker

Upvotes: 3

Led Machine
Led Machine

Reputation: 7552

Okay I found the answer, Right click to the Android Project -> Properties -> Android Options

Find linking and set it to none.

enter image description here

Then Rebuild your project

Upvotes: -1

Related Questions