xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.47k stars 514 forks source link

DLLNotFoundException for Xamarin iOS with SkiaSharp. (issue goes away on clean build, for 1 time only) [Enterprise Certificate Signing Identity] #9068

Open glintpursuit opened 4 years ago

glintpursuit commented 4 years ago

Steps to Reproduce

  1. Run the application. (in debug mode)
  2. Access skiashap, works fine. (in debug mode)
  3. Second time, run the application (in debug mode)
  4. Access skiasharp & we will get below error. If I clean & then run application it will work for 1 time.
System.DLLNotFoundException
@rpath/libSkiaSharp.framework/libSkiaSharp

Expected Behavior

  1. App should run without error.

Actual Behavior

  1. App is failing with dll not found exception while running.

Environment


=== Visual Studio Community 2019 for Mac ===

Version 8.6.5 (build 23)
Installation UUID: 036f5caf-5a99-4b4d-9f43-cca6b1d5bef0
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 610000104

=== Mono Framework MDK ===

Runtime:
    Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
    Package version: 610000104

=== Roslyn (Language Service) ===

3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

=== NuGet ===

Version: 5.6.0.6591

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.301/Sdks
SDK Versions:
    3.1.301
    3.1.300
    3.1.202
    3.1.200
    3.1.102
    3.1.101
    3.1.100
    3.0.101
    2.1.701
    2.1.700
    2.1.505
    2.1.302
    2.1.300-preview2-008533
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    3.1.5
    3.1.4
    3.1.2
    3.1.1
    3.1.0
    3.0.1
    2.1.19
    2.1.18
    2.1.17
    2.1.16
    2.1.15
    2.1.14
    2.1.12
    2.1.11
    2.1.9
    2.1.2
    2.1.0-preview2-26406-04

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.5 (16139)
Build 11E608c

=== Xamarin.Mac ===

Version: 6.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:04-0400

=== Xamarin.iOS ===

Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

=== Xamarin Designer ===

Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

=== Xamarin.Android ===

Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/abhijeet/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        5.0 (API level 21)
        5.1 (API level 22)
        6.0 (API level 23)
        7.0 (API level 24)
        7.1 (API level 25)
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.2
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/abhijeet/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

=== Android Device Manager ===

Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

=== Build Information ===

Release ID: 806050023
Git revision: 5289d413b99fddfc20b4ecf3e445ccb822213427
Build date: 2020-06-18 12:08:30-04
Build branch: release-8.6
Xamarin extensions: 5289d413b99fddfc20b4ecf3e445ccb822213427

=== Operating System ===

Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
    Tue May 26 20:41:44 PDT 2020
    root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

XAML Styler 2.0.1
mattleibow commented 4 years ago

Just adding a test project here: TestProject.zip

I don't yet have an enterprise account, but it does work on my local, personal account. I'll talk to people and get access to a an account.

@glintpursuit can you confirm that I have the correct style of project and it does not work.

mattleibow commented 4 years ago

Also, @glintpursuit can you provide a build log if it doesn't work and information if it runs on a simulator or device. Maybe Apple is doing something...

mattleibow commented 4 years ago

@AlexanderPBrown can you also let us know about the success of the simulator vs device and whether the project works.

mattleibow commented 4 years ago

To also provide better logs for us to work from, could you attach any binlogs or a detailed MSbuild log? Also, it might be very helpful to set the mtouch verbosity it detailed as well by setting -v -v -v -v in the Additional mtouch arguments.

You can follow the steps here: https://docs.microsoft.com/en-us/xamarin/cross-platform/troubleshooting/questions/version-logs#verbose-build-output-logs

glintpursuit commented 4 years ago

Just adding a test project here: TestProject.zip

I don't yet have an enterprise account, but it does work on my local, personal account. I'll talk to people and get access to a an account.

@glintpursuit can you confirm that I have the correct style of project and it does not work.

Unable to reproduce issue in TestProject. (After updating packages as well)

glintpursuit commented 4 years ago

@mattleibow Below line throws the error in my application

SKBitmap bitMap = SKBitmap.Decode(new MemoryStream(mediaFileBytearray));

System.DllNotFoundException has been thrown @rpath/libSkiaSharp.framework/libSkiaSharp

Attached are the logs when error & no error. Build Logs.zip

mattleibow commented 4 years ago

Having a look now... nothing seems to be out, it is linking with SkiaSharp but appears not to be copied into the package for some reason.

What happens if you install all the same packages or reference all the same projects. Maybe one reference has a targets file that is doing something wrong.

glintpursuit commented 4 years ago

@mattleibow You mean to have package added only in base project ?

I tried same, but then iOS says framework is missing for SkiaSharp.

This happening only for iOS, Android is working fine.

mattleibow commented 4 years ago

You need to install the iOS head/app project as well.

glintpursuit commented 4 years ago

You need to install the iOS head/app project as well.

Got you, no success.

Kioshilol commented 4 years ago

You need to install the iOS head/app project as well.

Got you, no success.

Do u solve this issue? got the same

glintpursuit commented 4 years ago

You need to install the iOS head/app project as well.

Got you, no success.

Do u solve this issue? got the same

No, didn't checked from last 2 months.

avorobjovs commented 3 years ago

I have the same issue on iOS 14.2

An error occurred: '@rpath/libSkiaSharp.framework/libSkiaSharp assembly: type: member:(null)'. Callstack: ' at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_picture_recorder_new() at SkiaSharp.SKPictureRecorder..ctor () <0x1178d9a28 + 0x00002> in <659007ac60e94125a4c9f512b9669a79>:0

shugaoye commented 2 years ago

I have this problem in .NET MAUI build as well.


[0:] System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.
 ---> System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKAbstractManagedStream..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)
   at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)
   at SkiaSharp.SKCodec.Create(Stream stream, SKCodecResult& result)
   at SkiaSharp.SKCodec.Create(Stream stream)
   at SkiaSharp.SKBitmap.Decode(Stream stream)
   at KeePassLib.Utility.GfxUtil.LoadImage(Byte[] pb)
   at PassXYZLib.PxItem.LoadImage(Byte[] pb, String faviconUrl) in D:\src\github\PassXYZLib\PassXYZLib\PxItem.cs:line 166
   at PassXYZLib.PxItem.SetIcon(Item item) in D:\src\github\PassXYZLib\PassXYZLib\PxItem.cs:line 414
   at PassXYZLib.PwGroupEx.GetItems(PwGroup group) in D:\src\github\PassXYZLib\PassXYZLib\PxGroup.cs:line 78
   at PassXYZ.Vault.Services.DataStore.get_Items() in D:\src\github\learning.netmaui\PassXYZ.Vault\Services\DataStore.cs:line 76
   at PassXYZ.Vault.Services.DataStore.GetItemsAsync(Boolean forceRefresh) in D:\src\github\learning.netmaui\PassXYZ.Vault\Services\DataStore.cs:line 241
   at PassXYZ.Vault.ViewModels.ItemsViewModel.ExecuteLoadItemsCommand() in D:\src\github\learning.netmaui\PassXYZ.Vault\ViewModels\ItemsViewModel.cs:line 79
**System.TypeInitializationException:** 'The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.'```
neallinAPJ commented 1 year ago

I have this problem in .NET MAUI build as well.

[0:] System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.
 ---> System.DllNotFoundException: libSkiaSharp
   at SkiaSharp.SKAbstractManagedStream..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)
   at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)
   at SkiaSharp.SKCodec.Create(Stream stream, SKCodecResult& result)
   at SkiaSharp.SKCodec.Create(Stream stream)
   at SkiaSharp.SKBitmap.Decode(Stream stream)
   at KeePassLib.Utility.GfxUtil.LoadImage(Byte[] pb)
   at PassXYZLib.PxItem.LoadImage(Byte[] pb, String faviconUrl) in D:\src\github\PassXYZLib\PassXYZLib\PxItem.cs:line 166
   at PassXYZLib.PxItem.SetIcon(Item item) in D:\src\github\PassXYZLib\PassXYZLib\PxItem.cs:line 414
   at PassXYZLib.PwGroupEx.GetItems(PwGroup group) in D:\src\github\PassXYZLib\PassXYZLib\PxGroup.cs:line 78
   at PassXYZ.Vault.Services.DataStore.get_Items() in D:\src\github\learning.netmaui\PassXYZ.Vault\Services\DataStore.cs:line 76
   at PassXYZ.Vault.Services.DataStore.GetItemsAsync(Boolean forceRefresh) in D:\src\github\learning.netmaui\PassXYZ.Vault\Services\DataStore.cs:line 241
   at PassXYZ.Vault.ViewModels.ItemsViewModel.ExecuteLoadItemsCommand() in D:\src\github\learning.netmaui\PassXYZ.Vault\ViewModels\ItemsViewModel.cs:line 79
**System.TypeInitializationException:** 'The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.'```

I have the same issue, did you have a solution?

AlexanderSCK commented 1 year ago

Same issue here

developTm commented 1 year ago

Hi, is there any update for fixes on this type of error?

denhaandrei commented 1 year ago

no fixes?

najak3d commented 1 year ago

I'm still on .NET 4.7.2, using Xamarin Forms, and ALSO getting this error for the XAML:

image

Here is my simple XAML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:keepScreenOn="true">
    <SkiaSharp.Views.Android.SKCanvasView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/FullImageViewSkia"
        android:layout_marginTop="0dp"
        android:layout_marginLeft="0dp"
        android:layout_marginBottom="0dp"
        android:layout_marginRight="0dp" />
</LinearLayout>

If I simply change it to "SkiaSharp.Views.Android.SKSurfaceView", instead of SKCanvasView, then it works.

I'm on Android, so for me, on Android, it seems that SKSurfaceView is probably more appropriate for my situation - as we're implementing our entire app as a full-screen image (like a game, but rendered to a SKBitmap, and blitted to the screen).