Xamarin.GooglePlayServices.Basement Fails Build - c#

We have a cross platform mobile application solution built on top of Xamarin targeting Android and UWP. On every solution build there is roughly a 50/50 chance of receiving the following error:
Error : Could not load assembly 'Xamarin.GooglePlayServices.Basement,
Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't
exist in the Mono for Android profile? at
Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
reference, ReaderParameters parameters) at
Xamarin.Android.Tasks.GetAdditionalResourcesFromAssemblies.<>c__DisplayClass37_0.b__1()
at System.Threading.Tasks.Task.InnerInvoke() at
System.Threading.Tasks.Task.Execute()
When receiving the error, if I turn around and immediately build the solution again the issue generally goes away. To further complicate the matter any of the Android projects in the solution can report this error, meaning it's not a single project giving me the problem. While annoying on my local machine, this introduces a lot of clutter when our CI-builds are constantly failing only to work when re-queuing the build.
I have attempted to remove and re-add the Xamarin nuget packages to the project. I've even deleted all the project files and created brand new ones, to no avail.
Any suggestions?

Related

How to resolve the conflict between 2 mscorlib versions in Visual Studio and Xamarin Studio?

For more than 2 days I have been trying to fix this error, but I have not succeeded.
This is the error :
No way to resolve conflict between "mscorlib, Version=2.0.5.0,
Culture=neutral, PublicKeyToken=7cec85d7bea7798e" and "mscorlib".
Choosing "mscorlib, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e" arbitrarily.
I searched about it and so many people had this problem, but I couldn't find a solution for it.
Finally, how can we find a way to resolve the conflict between these 2 references?
Issue I Faced: No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral,...............
Till now I have not succeeded in finding out the root cause, but I followed the steps to resolve the issue,
Open Android device manager, and try starting the android simulator of interest.
If it launches and states some error: stating to do a "Factory Reset", Stop the simulator and do the same.
Try Starting the Simulator, it works.
Hope this works for you too!!!
I don't have an answer but can provide the following:
I have a blank Xamarin.Forms app targeted only to Android. I can build and deploy this one without any errors.
I downloaded a Xamarin.Forms example from the Xamarin website and kept only the Android version. In this case I can rebuild the solution without any errors; however, when I try Start Without Debug, I get the exact error you report.
From these results I gather the following:
The conflict between mscorlib versions is not related to the configuration of Visual Studio 17 but to the configuration of the app.
The second of the links you included mentions installing a specific version of newtonsoft.json. Since this is a Nuget package, I thought that the problem would be with specific versions of these packages. Both of my apps use the same packages, but maybe the debug process doesn't necessarily use the same features of those packages.
I hope this helps.

Xamarin "GenerateResourceDesigner" task failed unexpectedly and .dll file could not be found

Hi I'm running a Xamarin PCL project thats deploying to all platforms including UWP windows 10 and windows 8.
I've just merged a branch on git and resolved some conflicts (not very well clearly) and i'm getting a few errors.
The first error:
The "GenerateResourceDesigner" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'Vigour, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Vigour.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.GenerateResourceDesigner.<Execute>c__AnonStorey0.<>m__0(String ass)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at Xamarin.Android.Tasks.ResourceDesignerImportGenerator.CreateImportMethods(IEnumerable`1 libraries)
at Xamarin.Android.Tasks.GenerateResourceDesigner.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Vigour.Droid
The second one:
I know this is a common problem and I've tried to un-tick and tick the build of each project in the solutions configuration.
I've also tried to remove the .vs/../.suo file to reset the project
However I've had no luck. I think that it might have something to do with the merger that involved changing the .csproj files.
Try to set API to 23 and then Rebuild the project it will solve the problem
Solution to this was to reinstall the xamarin forms for android and as #hvaughan3 said, deleting the bin and obj folder for all directories along with the packages.
In my case, I was getting error The "ResolveLibraryProjectImports" task failed unexpectedly. when I open a project downloaded from Xamarin.University on Windows 10 and the path for one of the files ends up being to long (longer than 260 characters). So, to solve my problem, I would copy the directory as shallow as possible, so instead working directly in the structure of downloaded project, I would copy deepest directory containing the project into my C:. Building would work then without an issue as the path to all files in the project got shortened.
So, say my downloaded structure from Xamarin.University is something like
C:\Users\me\Desktop\XAMARIN\XAMARIN CERTIFICATION\forms\xam300-advanced-cross-platform-development\Lab Materials\Part 03 Resources\Completed
I would copy the Completed folder into C and end up with much shorter path like:
C:\Completed

Xamarin App builds and runs on simulator, but on real phone I get Assembly Failure

I am working on a Xamarin based mobile app. It has previously deployed to an iPhone, and is currently working on the simulator. However, when I try to Debug on my iPhone, I get:
Error MT2002: Failed to resolve assembly: 'PCLStorage.Abstractions, Version=1.0.2.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64' (MT2002) (My_App.iOS)
PCLStorage is installed and up to date in my iOS and Core projects, although neither have any references to the package. It was installed when I added the AWS Core SDK. How do I resolve this error, I assume that is what is stopping the debug on iPhone?
Edit: (based on Answer below)
If I disable the linker in my build settings, I get the error:
My_App/iOS/MTOUCH: Error MT3001: Could not AOT the assembly 'My_App/iOS/obj/iPhone/Debug/build-iphone4.1-9.2.1/mtouch-cache/Build/AWSSDK.Core.dll' (MT3001) (My_App.iOS)
I would really appreciate some suggestions as I haven't made much headroom with this...
Try disabling "Linker" in the build options for Device builds. It's possible that if you are not directly referencing the library, the linker is stripping it out, causing it to fail at runtime.
I just had the same problem after switching from the simulator to an actual device
Fortunately, I've gotten the error only in 3 pages...
Fix was to remove the assembly attribute from the XAML:
From
xmlns:viewModels="clr-namespace:XXX.ViewModels;assembly=XXX"
To
xmlns:viewModels="clr-namespace:XXX.ViewModels"

Callisto multiple reference errors

Recently I tried to install callisto 1.1.0 and 1.2.6 for a windows store application. But after installation my application stopped running and popped out this error
Error 1 An assembly with the same simple name 'Callisto,
Version=1.2.6.0, Culture=neutral, PublicKeyToken=null has already been
imported. Try removing one of the references or sign them to enable
side-by-side. c:\Program Files (x86)\Microsoft
SDKs\Windows\v8.0\ExtensionSDKs\Callisto\1.2.6\References\CommonConfiguration\neutral\Callisto.dll Callisto_AppBar
I tried removing the dll files from the installed location and reinstalling the latest version of callisto. But still the same error is popping up. It would be great if someone could share a solution for it.
You can't have multiple versions of this library in your project...only one is permitted.

NSevriceBus Assembly Version Error

I have an issue when trying to load the NServiceBus assembly from a client machine. The software runs correctly from my development box but once rolled out I get the following error:
Could not load file or assembly 'NServiceBus, Version=2.0.0.1100, Culture=neutral, PublicKeyToken=9fc386479f8a226c' or one of its dependencies. The system cannot find the file specified.
The weird thing is I am not using version 2.0.0.1100, I am using the latest version 2.0.0.1219. It seems to be referencing the old version somewhere but I cannot find where. I have set the “Specific Version” flag to true on both the NServiceBus & NServiceBus.Core assemblies and have tried to explicitly set the version number in the app config, both with no luck. I don’t understand why it works fine locally but errors once rolled out. The project causing the error is a shared class library and it only appears to be erroring on some projects too.

Categories