Closed TimBo93 closed 6 years ago
You hit a bit of an edge case here.
Take a look at your obj/project.assets.json
file to see exactly what nuget resolved to use in terms of versions of implicit dependencies...
Basically, Xamarin.Forms 2.4.0.x wants v23.3.0 of Android Support libraries. Adding the CustomTabs v26.1.0.1 reference brings in Support.Compat 26.1.0.1 which brings in Annotations 26.1.0.1. Now, since none of the dependencies in the path of CustomTabs 26.1.0.1 depend on Support.v4 directly, there's really nothing linking it together with any of the shared dependencies of Xamarin.Forms, so this configuration is sort of technically ok, even though it obviously causes issues. What ends up happening is support.v4 v23.3.0 and support.compat 26.1.0.1 both contain some of the same classes (support v4 was split up in later versions and is really just a type forwarding library with no actual java classes embedded). This is why you're seeing the error.
Now to fix it, you basically need to add some more explicit <PackageReference declarations.
For instance, try adding:
<PackageReference Include="Xamarin.Android.Support.Design">
<Version>26.1.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v4">
<Version>26.1.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat">
<Version>26.1.0.1</Version>
</PackageReference>
Hi I @Redth I have the same issue, I added the explicit version, but still have the issue. I´m also using the IdentityModel.OidcClient.
I´m using windows and visual studio 2017.15.5
@danielmeza can you add a gist of your obj/project.assets.json
file? I suspect it's resolving some mismatched Xamarin.Android.Support.* package versions...
@Redth my apologies, it build ok but I get this warning
warning : Ignoring C:\Users\...\.nuget\packages\system.runtime.compilerservices.unsafe\4.4.0\ref\netstandard2.0 as it is a Reference Assembly
and when I try to debug I get the followin error:
12-15 13:57:39.699 F/monodroid-assembly(27062): Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration. 12-15 13:57:39.699 F/monodroid-assembly(27062): This might be due to an invalid debug installation. 12-15 13:57:39.699 F/monodroid-assembly(27062): A common cause is to 'adb install' the app directly instead of doing from the IDE.
I followed the instructions here:
But nothing work for me.
The project file Litigio.Mobile.Android.zip
The project.assets.json file project.assets.zip
And it is related wiht this issue to. https://forums.xamarin.com/discussion/100273/deploying-to-android-emulator-error-could-not-load-assembly-system-runtime-compilerservices-unsafe
I temporaly solve the issue of the runtime exception, only change the Linker option in the android project from none to Sdk and User Assemblies and in iOS projec to fron none to Link Framework SDKs Only option.
I have the same problem with latest xamarin forms(.net standard) and realm only for xamarin android
exactly the same as @listepo
I have the same issue. Except I'm using EntityFrameworkCore.SQlite
Is there any traction on a fix here? None of the workarounds seem to work for me
@ConX-Ryan did you try to change the Linker options?
@danielmeza - I tried the Linker option and found that my Bindings stopped working (on Droid and iOS). Anyone have other solutions for this system.runtime.compilerservices.unsafe issue?
@gesch80550
I tried the Linker option and found that my Bindings stopped working (on Droid and iOS). Anyone have other solutions for this system.runtime.compilerservices.unsafe issue?
It is normal to see that after change the Linker options and it is beacuse the linker are removing code that it is necesary to run your application, to solve the issue of broken binding you can add [Preserve(AllMembers = true)] on all class on your code or you can exlcude the entire proyect. Note the Litigo.Mobile.Forms word in the Skip linkin assembly, that must solve your binding issue, in iOS is not necesary to put the linker option to full, you can only link the SDK Assemblies
This issue is actually one of https://github.com/xamarin/xamarin-android
There are a number of issues which are referring to this same problem: https://github.com/xamarin/xamarin-android/issues/1162 https://github.com/xamarin/xamarin-android/issues/1196 https://github.com/xamarin/xamarin-android/issues/1154
Basically, the only current work around for this is to switch your projects to use packages.config instead of <PackageReference
until a proper fix is released.
Change to packages.config not solve the problem... it must remain open.
The issue is traking here https://github.com/xamarin/xamarin-android/issues/1196
Xamarin.Android Version (eg: 6.0):
8.0 (Oreo)
Operating System & Version (eg: Mac OSX 10.11):
Windows 10 1709
Support Libraries Version (eg: 23.3.0):
Android 5.0 (API Level 21 - Lollipop)
Describe your Issue:
To implement SSO with IndentityServer i am trying to use ChromeCustomTabs as described here: IdentityModel/IdentityModel.OidcClient.Samples
Now i want to add Xamarin.Forms support.
Steps to Reproduce (with link to sample solution if possible):
Install Xamarin.Forms Nuget with Version
Include any relevant Exception Stack traces, build logs, adb logs:
I remove /bin /obj restored nuget and restarted vs. It seems to be that some references are broken with the current (stable) Xamarin.Forms Package.
Kind Regard Tim