我最近给自己买了一个 PinePhone,并决定尝试使用 .NET Core 5。我选择使用 Avalonia,因为它宣传的跨平台特性。我将该应用程序部署到我的手机并遇到了该错误:
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
奇怪的是,libSkiaSharp.so
库文件与可执行文件位于同一文件夹中。该文件夹是通过以下 dotnet publish
命令创建的:
dotnet publish -r alpine-arm64 DummyCounter -o ./publish
我尝试了一些不同的方法,将架构更改为 linux-musl-arm64,将应用程序部署为独立和/或单文件,但我仍然得到完全相同的结果。以前有人见过这样的吗?
答案 0 :(得分:2)
ARM64 Linux 支持开箱即用。然而,ARM64 Alpine Linux 需要自定义构建 SkiaSharp,因为与其他 Linux 发行版不同,Alpine 使用的是非标准版本的 libc。
所以要么切换到更主流的东西,要么按照说明构建 SkiaSharp - https://github.com/mono/SkiaSharp/wiki/Building-on-Linux