Xamarin Studio Mac, Portable class library, Async and Android - asynchronous

Edit: On the Alpha Channel Profile7, Profile49 and Profile78 seem to work.
I'm working with the setup that was described here:
Getting PCL, Mvvmcross, Nuget and Xamarin Studio to play "nice" on Mac .
How do you make a PCL in Xamarin Studio with Async support work.
I'm usually using Profile104 which is TargetFrameworkVersion v4.0
I tried the following combinations of the hree different v4.5 profiles
Profile7, Profile49, Profile78 with the different versions of Xamarin Studio:
Profile7 Profile 49 Profile 78
Alpha (4.1.10, mono=3.2.2) 1 1 1
Beta (4.0.12, mono=3.2.1) 2 2 2
Stable (4.0.12, mono=3.2.0) 1 1 1
System.Type, System.Threading not found. Unusable
Profile not found: /Library/Frameworks/Mono.framework/Versions/3.2.1/lib/mono/xbuild/Microsoft/Portable/v4.5/Microsoft.Portable.CSharp.targets is missing
Basically none of the 4.5 profiles is working in any of the currently available Xamarin Studio versions for Mac.

Edit: These instructions apply to the Stable Channel. On the Alpha channel you can use Profile 158, v4.0 which works fine with async.
The following setup seems to work with Android, haven't tried with Touch.
Set your PCL-Project to 4.0 Profile 104, in your csproj the lines are:
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
On your PCL-Project, "Manage Nuget packages", search for Async, Add the package with the ID: Microsoft.Bcl.Async
Your async code should now compile in the PCL, however the Android project will complain about missing dlls and you can't (or maybe shouldn't) add the Async Targeting Pack to it.
On the Android project, Options, Build/Android Build, on the Linker tab, add the following to "Ignore assemblies": System.Threading.Tasks.dll;Microsoft.Threading.Tasks.dll;Microsoft.Threading.Tasks.Extensions.dll. My csproj contains the following lines:
<AndroidLinkSkip>System.Threading.Tasks.dll;Microsoft.Threading.Tasks.dll;Microsoft.Threading.Tasks.Extensions.dll</AndroidLinkSkip>
You might need to restart Xamarin Studio, on my machine the "Ignore assemblies" didn't work immediately on one of the Droid test projects.
Your Android project should now build and deploy with async support in a PCL dependency.

Related

Unable to install device agent in iOS 13

I tried to run xamarin ui test for iOS, it getting working on my iPhone iOS version 12.
When I tried it with iOS13 getting exception
Xamarin.UiTest.XDB.DeviceAgentException: Failed to install device agent.
I tried multiple xamarin ui test version none of them working.
Currently I am using
Xamarin.UiTest 3.0.7
Nunit 2.6.4
NunitTestAdapter 2.2.0
Definitely a bug in the UITest Nuget package that seems to be recurring since v3.
Have you tried the newer version of the Nuget package: 3.0.8-dev1? It may only be available in the Alpha channel.
I would recommend going here and tapping on "Contact Owners" to report the bug.
To verify that it's not just your issue, you could quite Visual Studio, delete all the bin and obj folders, delete the app from your phone and then try again (or just git clean -fxd if you have a .gitignore file)

How do I verify if I'm using the native iOS SQLite provider, and how do I correct it?

I'm using a new project that's using sql-lite-pcl and it doesn't appear to be loading the required dependency packages (recursively). I know this because "it just doesn't work (tm)"
I've been able to get the project to work by adding the following on the Xamarin Forms project and the iOS project
SQLite-net-pcl
SQLitePCLRaw.bundle_green
SQLitePCLRaw.core
SQLitePCLRaw.lib.e_sqlite3.ios
SQLitePCLRaw.provider.dynamic_cdecl
SQLitePCLRaw.provider.internal.ios_unified. (iOS only)
SQLitePCLRaw.provider.ios_inified (iOS only)
For most of the items above I needed to install a 1x version, whereas the 2.0 version of SQLite reported a variety of errors from the SQLite-net-pcl library. (there is an open GIT issue on the project page for 2.0 support)
Question
How do I verify (in runtime?) that I'm using the native iOS provider?
Does it matter if I switch between the iOS provider and the code- based one? In either data binary reading and writing, locks, app suspension/closing handles, performance or any other reason?
What are the correct libraries to load if simply adding sql-lite-pcl into a Visual Studio for Mac doesn't recursively load all dependencies, and the correct version of them?
There is a very good tutorial how to use SQLite for Xamarin Forms. You can find it here.
It's working fine both for Android and iOS version

Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found in Xamarin UWP

Already found the same problem here.
My error:
Severity Code Description Project File Line Suppression State
Error CS7069 Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found
The solution on that thread is downgrade the xamarin forms to version 2.5.1.527436 in all the projects. But I can't do that in my project, because I am using some features that are available in latest xamarin forms like android bottom tab feature, autosize property of editor and flowdirection property of listview.
I have this problem after updating xamarin forms to 3.4.0.1008975 from 2.5.0.121934. Problem is only on the UWP part. Android and IOS apps are working fine.
Error lines:
var rendererAssemblies = new List<Assembly>
{
typeof(ImageCircleRenderer).GetTypeInfo().Assembly
};
rendererAssemblies.AddRange(Rg.Plugins.Popup.Popup.GetExtraAssemblies());
Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e, rendererAssemblies);
So how can I fix this issue without downgrading Xamarin.Forms?
Update
Facing the same problem again for another project. But the solution here is not fixing the error. Changed the target version of windows project to windows 10, version 1809(10.0;Build 17763) and min version to Windows 10 Fall Creators Update(10.0; Build 16299). Screenshot adding below: please suggest a solution.
Xamarin.Forms Version: 3.4.0.1008975
As the linked thread mentions, the problem is that your app has to have min UWP version set to Fall Creators Update (16299), because this is the first release that supports .NET Standard 2.0.
In version 3.0 Xamarin.Forms dropped support for Portable Class Libraries and is now targeting .NET Standard 2.0 only. This means you must target at least Fall Creators Update (16299) in UWP to make sure it can be referenced.
To retarget your UWP project to the newer version, right-click the UWP project node in Solution Explorer, select Properties and then use the two dropdowns to select at least version 16299 in both.
Changing the Min version should be okay as long as you don't need to support Windows 10 Mobile, because absolute majority of users is already on version 1803 and Fall Creators Update is version 1709. See following usage graph (by AdDuplex)

Xamarin.Forms - Xamarin.Forms.Maps broken references in Droid Project

I need to implement Map functionality into an application that I'm building.
And I was folliwing this guide.
I downloaded the package and did all of the configuration.
I haven't implemented the Map class into my project yet, I only did the configuration required for both platforms (Android and iOS).
The Portable project and the iOS project are fine, the problem here is the Android project.
It has some broken references, these ones:
And when I try to compile the Android project, I get this error and these warnings:
Can anybody give me a hand? Thanks in advance.
EDIT:
As a sidenote, I'm using the Sdk installed by Android Studio, and that one has the latest Google Play Services installed.
UPDATE:
I just upgraded the version of my Xamarin.GooglePlayServices one by one (the one listed up there in the first image) for some reason it downloaded a really old version of those. So I just upgraded them, and it seems those references are fine now.
But I still get the error:
The "ResolveLibraryProjectImports" tasks failed unexpectedly.
SOLUTION:
I unloaded the Android project, added this:
<UseShortFileNames>True</UseShortFileNames>
To every property group in the .csproj file.
Load my android project back, and it all worked fine now.

Xamarin with Entity Framework Core: Error: unauthorized access to "/system/lib/libsqlite.so" on Android 7

Im trying to create a Xamarin Forms App using the new Entity Framework Core. The app targets android 6.0 but my Emulator is running Android 7.0. I installed the following related Nuget packages on the android project:
Microsoft.EntityFrameworkCore --> 1.1.1
Microsoft.EntityFrameworkCore.Sqlite --> 1.1.1
When accessing my DbContext on Android a message will pop up telling: Detected problems with native libraries unauthorized access to "/system/lib/libsqlite.so".
This Xamarin forums thread suggests, that it's due to the native SqLite binaries are no longer supported (on Android 7?) and the common fix seems to be to switch to the SqLite.Net PCL.
However as Microsoft.EntityFrameworkCore.Sqlite depends on Microsoft.Data.Sqlite which in turn depends on the native SqLite package I cannot just replace this (or can I?)
Strangely enough, despite of the error message suggesting otherwise, the data access seems to work. At least migrations run and repeated writes to the database will create new Ids.
Of course I could just scrap EF Core but I guess a lot of people are looking into using it for Xamarin in the future. So it would be nice if anyone would find/know a fix.
I had the same problem. I have fixed this using the following libs: sqlite-net-pcl (version 1.2.0), SQLitePCLRaw.bundle_green, SQLitePCLRaw.core, SQLitePCLRaw.lib.e_sqlite3.android, SQLitePCLRaw.provider.e_sqlite3.android.
Matheus Souza had the right idea there. However installing SQLitePCL is only part of the answer. Here is how I eventually solved this:
DISCLAIMER: This is a kind of "You can do it but it isn't pretty"-solution. If you have the time, it's probably best to wait for the official Microsoft.EntityFrameworkCore.Sqlite 1.2.0 release.
This issue brought me on the right track. The new (unreleased) version of EntityFrameworkCore no longer uses the native sqlite binaries, but sqlite-net-pcl. This is the steps I followed to install it:
Add the aspnetcore-dev branch to your nuget feeds. Nuget 3: https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
Check "Show preview versions" in Nuget and update (or reinstall) all EntityFrameworkCore packages to "1.2.0 - preview"
(Make sure your x64 is checked in your android projects advanced build options, if the app instantly crashes on deploy. This might be unreleated)

Resources