1

I got myself a PinePhone recently and decided to play around with .NET Core 5. I chose to use Avalonia due to its advertised cross-platform nature. I deployed the app to my phone and got faced with that error:

Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library liblibSkiaSharp: No such file or directory
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at Avalonia.Skia.PlatformRenderInterface..ctor(ISkiaGpu skiaGpu, Nullable`1 maxResourceBytes)
   at Avalonia.Skia.SkiaPlatform.Initialize(SkiaOptions options)
   at Avalonia.SkiaApplicationExtensions.<>c__0`1.<UseSkia>b__0_0()
   at Avalonia.Controls.AppBuilderBase`1.Setup()
   at Avalonia.Controls.AppBuilderBase`1.SetupWithLifetime(IApplicationLifetime lifetime)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at DummyCounter.Program.Main(String[] args)
Aborted

Weirdly enough, the libSkiaSharp.so library file is present in the same folder as the executable. The folder was created through the dotnet publish command below:

dotnet publish -r alpine-arm64 DummyCounter -o ./publish

I've tried a few different things, changing the architecture to linux-musl-arm64, deploying the app as self-contained and/or single-file but I still get the same exact result. Has anyone seen anything like this before?

2 Answers 2

2

ARM64 Linux support works out of the box. ARM64 Alpine Linux, however, requires a custom build of SkiaSharp since Alpine, unlike other Linux distros, is using a non-standard version of libc.

So either switch to something more mainstream or follow instructions for building SkiaSharp - https://github.com/mono/SkiaSharp/wiki/Building-on-Linux

1
  • Thank you, I tried to create a custom build of SkiaSharp for postmarketOS which is an ARM64 Alpine Linux but it didn't seem to work. However, switching to Plasma Mobile the app worked without further changes. Feb 9, 2021 at 11:37
0

A few weeks ago I revisited the issue on a Pinephone running postmarketOS with the same piece of code. All it took was updating all the packages after the 2022 mobile release of Avalonia, including the SkiaSharp dependency, to their most recent versions worked. I even wrote a blog post to celebrate: https://www.codingnagger.com/2022/04/19/at-last-the-dummy-counter-runs-on-postmarketos/

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.