Repository navigation
Closed
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.vs-syncFor internal use only; creates a VSTS "mirror" issue.
Milestone
Description
Steps to Reproduce
- Get and Build repro https://github.com/marcominerva/XamarinAndroidIssue
If you instead the build log you will see that
Using "ResolveAssemblies" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll".
has few ...ref/netstandard2.0/... references which is wrong as they should never be used as an input to linker or any post compilation processing
This issue is possibly related to #1154
Expected Behavior
No error during execution.
Actual Behavior
[Mono] Assembly Loader probing location: 'System.Memory'.
[monodroid-assembly] Could not load assembly 'System.Memory' during startup registration.
Version Information
Xamarin.Android
Version: 8.1.0.25 (Visual Studio Community)
Android SDK: /Users/marek/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
7.1 (API level 25)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.3
Log File
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1500,2): warning : Ignoring /Users/marek/.nuget/packages/system.buffers/4.4.0/ref/netstandard2.0 as it is a Reference Assembly
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1500,2): warning : Ignoring /Users/marek/.nuget/packages/system.memory/4.4.0-preview2-25405-01/ref/netstandard2.0 as it is a Reference Assembly
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1500,2): warning : Ignoring /Users/marek/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0 as it is a Reference Assembly
VS bug #585873
Metadata
Metadata
Assignees
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.vs-syncFor internal use only; creates a VSTS "mirror" issue.
Activity
[-]ResolveAssemblies tasks uses reference assemblies[/-][+]ResolveAssemblies task wrongly uses reference assemblies[/+]GMariakis commentedon Jan 11, 2018
Until this is resolved, has a workaround been identified? Having this issue with System.Memory and System.Runtime.CompilerServices.Unsafe
dellis1972 commentedon Jan 11, 2018
The only thing I can think of is to add a reference to the missing assemblies to the main app. And make sure you reference the
libversions.GMariakis commentedon Jan 11, 2018
That does not work. I have tried all the workarounds, such as changing the linker, adding the packages.config, etc. URLs below.
I am trying to use SignalR Core in a Cross Platform Xamarin / Xamarin Forms app using .NET Standard as the code sharing mechanism. Getting the same two skips with the reason that it is a reference Assembly.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1500,2): warning : Ignoring /Users/xxxxxx/.nuget/packages/system.memory/4.4.0-preview2-25405-01/ref/netstandard2.0 as it is a Reference Assembly /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1500,2): warning : Ignoring /Users/xxxxxx/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0 as it is a Reference Assemblyhttps://forums.xamarin.com/discussion/113718/android-error-with-signalr-core-could-not-load-assembly-system-memory-during-startup-registration
https://forums.xamarin.com/discussion/100273/deploying-to-android-emulator-error-could-not-load-assembly-system-runtime-compilerservices-unsafe
https://github.com/aspnet/EntityFrameworkCore/issues/8922
rwasef1830 commentedon Jan 22, 2018
Here's a functioning workaround. It's hacky and ugly but works with minimum fuss. Put this in an XML file and
<Import>it in your Android csproj file at the end. It works at least for System.BuffersUpdate: Fixed an issue where if there were no ref assemblies in the list, the
ResolvedAssemblieswould be emptied. Symptoms of that issue: Build failure with cannot findobj\linksrc\SomeAssembly.dllor an assembly not found error. The bug fix was adding a condition to only empty ResolvedAssemblies if ResolvedAssembliesFixed was not empty.SvenEV commentedon Jan 22, 2018
I found another workaround: In my case, the NuGet package "System.Runtime.CompilerServices.Unsafe" caused the issue. So I made a copy of the package (*.nupkg file), removed the "ref"-folder from it (which contains the reference assemblies), and installed that modified package into my project.
Now that the package only contains the "real" assembly, there's no way for Mono to accidentally pick the wrong assembly.
dellis1972 commentedon Jan 22, 2018
That is an interesting workaround :) it that might cause some issues though. We are still working through this issue here, hopefully we will find a good soluition.
GMariakis commentedon Jan 22, 2018
The problem with any of these workarounds, once I get it to build and deploy, the Xamarin Forms won't find and attach property changed notify for any fields. I spent a week trying to figure out why. The only thing I can think of is that there's an internal problem with these pre-release libraries.
[Xamarin.Android.Build.Tasks] Better support for netstandard libraries.
danielmeza commentedon Mar 6, 2018
@SvenEV your soulution work perfectly, I just open the .nupkg with WinRar and remove the ref folder, also from the package folder and the the application work fine

[Xamarin.Android.Build.Tasks] Better support for netstandard libraries.
10 remaining items
[Xamarin.Android.Build.Tasks] Better support for netstandard libraries.
[Xamarin.Android.Build.Tasks] Better support for netstandard libraries.
[Xamarin.Android.Build.Tasks] Better support for netstandard librarie…
Release 1.1.0 (#157)
maddentist commentedon Apr 3, 2018
Any ETA for a fixed version of Xamarin.Android with these ?
rwasef1830 commentedon Apr 12, 2018
To whomever used my workaround, there's a bug in it that breaks your build if there are no referenced .net standard libraries that use ref assemblies. The code is fixed now so it works even on a fresh project. Updated the comment: #1162 (comment)
Release/1.2.0 (#170)
Realm backend (#148)
MagicAndre1981 commentedon Aug 24, 2018
@maddentist I had to switch to packages.config for the Android App and this fixed my issue
jrgsc commentedon Oct 19, 2018
I had this fix on my project for awhile now and completely forgot about it since. I loaded up my project on an updated version of VS and it wouldn't build. Took me awhile and a lot of sniffing around to figure out that this fix was the cause of my build issues. After removing it, my app now builds again.
Added fix for netstandard/android. See dotnet/android#1162 (comment)