Closed tipa closed 2 years ago
Any comments/updates on this?
Have you tried again with EF Core version 2.0.0 and Xamarin.Android 7.5?
How can I test it with Xamarin.Android 7.5? Version 7.4 was just released a few days ago
@tipa Xamarin Updater Extension for VS 2017 (market). For older version of VS you can switch channels in vs->options->xamarin (not sure if alpha or beta). I had the same error so I updated everything to the latest version, VS + NET Core (2.0+) + Xamarin Preview (I'm using Xamarin.Android 7.5.0.3 ), and everything is fine since then.
@erikpowa that means I am forced to use VS17 Preview in order to use Xamarin.Android 7.5, is that correct? I would probably even do that if that finally resolves that issue.
Edit: well, downloaded VS17 preview + Xamarin.Android 7.5, however they still seem to be very beta, I encounter several issues which make it impossible for me to even compile the app.
I have the same issue on the current stable and on the preview of Xamarin. But I still have the same issue..
(Marking for re-triage. Xamarin supports .NET Standard 2.0 now, but this still seems to be blocked.)
Hi, this is very serious for us, since we are already shipping the Android app with netstandard1.4. For now just no one use a Android 7+ phone, but now we might loose many important customers if we can't get it working very soon. Can you give me any advice on how to handle this? Is there any workaround to make it work on Android 7+? I'd be grateful for any help. Thanks.
If you target 6.0 with your app and use EF 1.x it should work on Android 7+ as well. There is a message shown sometimes when you start, but you can just hit ok and it should be functional.
Thank you! Didn't think there was an easy solution like this (though i also added this: https://github.com/aspnet/EntityFrameworkCore/issues/7870). For now this is the better solution anyway until we can upload UWP projects to the app store with netcore2.0 ;)
ah right. that one is also an important one :) Glad it worked :)
Any updates on this? Same problem exists with Xamarin.Android 8.0 and VS17 Update 4.
It seems the issue only appears with either project.json or package ref. With the old packages.config it seems to work so far. I have two projects attached, one with packages.config (App1) und eines mit packagesRef (App2).
I have the same problem, an update would be much appreciated
We're having the same issue using EF Core 2.0.1 in VS 15.4.3 and VS 15.5 Preview 3 with no luck.
This is annoying because the Xamarin application is now blocked because of this.
@alexdrl
Thanks - while both of your suggestions work, they feel like a workaround. Would be awesome if we wouldnt have to use them in the future
@erikpowa We are in the point 2, using PackageReference. I cannot install System.Runtime.CompilerServices.Unsafe 4.3.0 because EF Core 2.0.0 uses the 4.4.0 version, so NuGet detects a package downgrade, and does not let me install 4.3.0.
I investigated this a little. It seems like Microsoft.Extensions.Primitives
has a dependency on System.Runtime.CompilerServices.Unsafe
. When the Linker runs, it looks for the DLL in the directory of Microsoft.Extensions.Primitives
, which is not downloaded by NuGet.
I have downloaded the NuGet Package System.Runtime.CompilerServices.Unsafe
4.4.0, extracted the DLL and linked it with a normal Reference. This way it will be copied into the output directories and can be linked.
This is my previous workaround:
@alexdrl I think the following trick is necessary to make it work.
Manually edit the csproj
file of your project and define, that the NU1605
warning shouldn't be treated as an error:
<PropertyGroup>
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
Then in your Project File add the System.Runtime.CompilerServices.Unsafe
Package in Version 4.3.0
as mentioned by @erikpowa:
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.3.0" />
Then I would:
bin
and obj
foldersAfter a successful build your Xamarin App should start with Entity Framework 2.0. 👍
@bytefish @erikpowa That workaround worked good... as we're working closely to the latest version of .NET Core/Standard and Xamarin, could you give us some explanation of why is this happening?
Thank you for the workaround.
Also, as we have found with other package version mismatch, this package downgrade workaround breaks the assemblies linking.
When I add the System.Runtime.CompilerServices.Unsafe package I get an Exception during linking:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2153,3): warning MSB3277: Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void Microsoft.Extensions.Primitives.InplaceStringBuilder::Append(System.String,System.Int32,System.Int32)' in assembly: 'Microsoft.Extensions.Primitives.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Runtime.CompilerServices.Unsafe::CopyBlockUnaligned(System.Void*,System.Void*,System.UInt32)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: --- End of inner exception stack trace ---
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
So I have to set the linker to "None" instead of "SDK Assemblies only". Is there a work around for that? I already set the entry mentioned by @bytefish .
This happens on VS15.5.
Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
I have same issues when start a solution using Prism Template Pack (set only to Android), then i add Realm DB from Nuget packages. Without Realm, no issues I'm using Visual Studio 2017 with update 15.4 on Windows 10
@bytefish @erikpowa That workaround worked! Thanks!
@bytefish I included the linker.xml file with the suggested content, but no luck. This issue is now 6 months old and still we are using half baked workarounds that get broken with ever other VS or Xamarin release. Really frustrating...
@divega Can we follow up with the Xamarin Android team on this?
Thanks @bricelam. I started an email thread with the Xamarin folks to figure out with them how to best manage this and other issues that were reported here but appear to be Xamarin issues.
At least for now, I would like to make sure such issues are also marked area-external to distinguish them from any Xamarin-related issues we need to address on our side. Can you please help me make sure they are?
@bytefish fix works but requires the linker set to "Don't link". This is not good.
This is still an issue? is this being worked on or should i move to a more stable library for a new project?
I had to move to Dapper because of this problem which works great on mobile but doesn't do migrations.
I was using EF Core 2.0 just fine, and then issue only started occuring for me after I moved from packages.config
to packagereference
.
@bytefish
Adding a package reference to System.Runtime.CompilerServices.Unsafe
4.3.0
resulted in a package downgrade build error. I added the NoWarn
for that error which allowed the build to proceed - which now gets as far as this linker error:
2> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1696,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void Microsoft.Extensions.Primitives.InplaceStringBuilder::Append(System.String,System.Int32,System.Int32)' in assembly: 'Microsoft.Extensions.Primitives.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Runtime.CompilerServices.Unsafe::CopyBlockUnaligned(System.Void*,System.Void*,System.UInt32)
Linker set to SdkOnly
Any ideas?
We are tracking this issue in the following github issues:
https://github.com/xamarin/xamarin-android/issues/1154 https://github.com/xamarin/xamarin-android/issues/1196
Using packages.config instead of package references works around the problem.
Hey guys, not that it helps- but we had 3+ devs in our company alone run into this issue. So, for what it's worth, I don't think this is an isolated problem.
Latest Xamarin.Forms (.NET Standard) project + EntityFrameworkCore == runtime exception that only shows when deploying to an emulator.
Thanks, -Derek
@dfoulk it's even wider since it affects far more than EntityFrameworkCore. However, the workaround I've described does the job. For more details see https://github.com/xamarin/xamarin-android/issues/1196#issuecomment-358292869 and below.
@ddobrev - Yes, thank you for that. We're converting these projects to package.config- but a few errors seem to be preventing us from deploying still...
After following the instructions you provided in another thread:
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
No resource found that matches the given name: attr 'windowActionModeOverlay'.
styles.xml has apparently ran into some issues as a result :(
Update:
Something was wrong with our initial conversion. We reverted and tried again and all ended up okay... Thanks again!
@dfoulk you're welcome. About that error, your conversion was just fine - it's just that Xamarin.Android is notoriously poor at rebuilding. Every time a major restructuring, such as yours, takes place, the only way to properly rebuild everything is after deleting your bin/ and obj/ - that is, neither rebuild nor clean + build work in such cases.
Any news here? I cannot go back to 1.3 :( And really need EF with SQLite to work on our app in Android. How is this long delay of a fix even possible? :(
I am using it in our monodroid 8 app - it is working.. I had to convert the project to using packages.xml instead of packagereference though.. I'm waiting for this issue to be fixes so that I can convert back to packagereference and drop packages.xml again..
yes, it's the package reference scenario I want them to fix. It has been many converts back and forth already, because of other libs and I'm done spending time converting, my clients do not pay for that job :(
Clearing milestone to decide in triage whether we want to keep this for tracking purposes or whether we should close.
The underlying issues in Xamarin Android are now tracked in xamarin/xamarin-android#1154 and xamarin/xamarin-android#1196.
Thanks for the update @divega
I was successfully using
Microsoft.EntityFrameworkCore.SQLite v.1.1.2
in a Xamarin.Android project. But for Android 7+, the app crashes withunauthorized access to "/system/lib64/libsqlite.so"
(as reported here).So I updated to version
v2.0.0-preview1-final
as this should fix the issue. However, this results in other problems like the following where the app compiled, but crashed while deploying/starting on the emulator:I then tried to add the 'System.Runtime.CompilerServices.Unsafe' NuGet package manually to my project, but it didnt fix the problem. I messed around a lot, trying different build parameters and such and actually got the app running on an Android 7 emulator. However, after a project clean and rebuild, the error showed up again.
Any help on how to get EFCore Sqlite to work on Android 7?
Steps to reproduce
Sample project: https://github.com/tipa/EFCoreSample (Basically just the basic Android template from VS + the Nuget preview package)
Further technical details
EF Core version: v2.0.0-preview1-final Database Provider: Microsoft.EntityFrameworkCore.Sqlite Xamarin: 4.5.0.486 Xamarin.Android: 7.3.1.2 Operating system: Windows 10 IDE: Visual Studio 2017 15.2