Skip to content

RichTextKit/SkiaSharp on Android: Could not resolve type with token 0100000b from typeref (expected class 'System.ReadOnlySpan`1' in assembly 'mscorlib') #5142

@mikegoatly

Description

@mikegoatly

Description

When running a MAUI project on Android using RichTextKit to render text on a SkiaSharp SKCanvasView control the following exception is thrown:

System.TypeLoadException
  Message=Could not resolve type with token 0100000b from typeref (expected class 'System.ReadOnlySpan`1' in assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e')

Repo here: https://github.com/mikegoatly/MauiExperiments/tree/main/MauiRichTextKit

I'm guessing that code is being trimmed that's needed?

Steps to Reproduce

  1. Create a new MAUI project
  2. Add a package reference to SkiaSharp.Views.Maui.Controls
  3. Add .UseSkiaSharp() to MauiProgram
  4. Change MainPage.xaml to have this as content:
<Grid>
    <sk:SKCanvasView PaintSurface="SKCanvasView_PaintSurface"/>
</Grid>
  1. Add this to MainPage.xaml.cs:
private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Maui.SKPaintSurfaceEventArgs e)
{
  var text = new TextBlock();
  var styleManager = StyleManager.Default.Value;
  styleManager.FontSize(40);
  styleManager.HaloColor(SKColors.Red);
  styleManager.HaloWidth(4);
  styleManager.HaloBlur(2);
  
  text.AddText("Hello MAUI!", styleManager.CurrentStyle);
  
  text.Paint(e.Surface.Canvas, new SKPoint(100, 200));
}

Debug the app on Android (I'm using Pixel 5 - API 30 (Android 11.0 - API 30)) and get the error. Note that the app works fine when running as a Windows app.

Version with bug

Preview 13 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11 and up

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-drawingShapes, Borders, Shadows, Graphics, BoxView, custom drawingplatform/androids/triagedIssue has been revieweds/try-latest-versionPlease try to reproduce the potential issue on the latest public versiont/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions