I have a multiplatform app using Xamarin.Forms. While I can build for iOS and WindowsPhone 8.1, when I build for Android, I get the following build error
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'System.Void Android.OS.BaseBundle::PutString(System.String,System.String)' (defined in 'XLabs.Platform.Droid, Version=2.0.5679.29813, Culture=neutral, PublicKeyToken=null') from 'XLabs.Platform.Droid, Version=2.0.5679.29813, Culture=neutral, PublicKeyToken=null' could not be resolved.
I've searched around for a solution on this but cannot seem to find one or where on earth in my code this problem is coming from.
Does anyone know how to start solving this issue so I can submit a build?
Check that the Xamarin Forms NuGet package versions are the same in the XLabs version you are using and the Android Project. Normally a version mismatch is the cause for these errors.
Related
I keep getting this error when I try to run the app on release mode:
Severity Code Description Project File Line Suppression State Error
Can't resolve the reference 'System.Void
System.Security.Cryptography.DSACng::.ctor(System.Security.Cryptography.CngKey)',
referenced from the method 'T
Internal.Cryptography.Pal.Windows.PkcsPalWindows::GetPrivateKey(System.Security.Cryptography.X509Certificates.X509Certificate2,System.Boolean,System.Boolean)'
in 'System.Security.Cryptography.Cng, Version=4.3.3.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. LabelApp.iOS
I see on the internet that it is related to mailkit, however, I deleted all references to mailkit. On android, everything works fine and even on debug mode it works fine.
I already tried removing the references to mailkit and used older and newer versions of mailkit. I expected that the error would be resolved because this worked on another app I made in the past, but it didn't.
I fixed it. It seems that the problem was with a package called EPPlus which I used to export data to an excel file.
We are aware that in Xamarin.iOS, UIWebView will soon be deprecated and apps will not be accepted with deprecated versions.
I have created a new project here. I have followed this document here as well as other posts on internet to remove UIWebkit and replace it with WKWebview but it doesnt work.
Since its a new project, so no nuget packages are being used which could have had UIWebView. But still when i add --warn-on-type-ref=UIKit.UIWebView flag in mtouch arguments I get error:
One or more reference(s) to type 'UIKit.UIWebView' already exists
inside 'Xamarin.Forms.Platform.iOS, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null' before linking WebViewTest.iOS
How do I remove UIWebview complete from the basic project so my app can get accepted on testflight/appstore.
I am using Visual Studio 16.5.5 with Xamarin.iOS version 13.16 and I have tested on Xamarin forms 4.4 and 4.6 both
In project file WebViewTest.iOS.csproj remove --warn-on-type-ref=UIKit.UIWebView -warnaserror:1502 -warnaserror:1503
It should look like this
<MtouchExtraArgs>--optimize=experimental-xforms-product-type</MtouchExtraArgs>
Use latest Visual Studio for Mac
also set Linker behavior to SDK framework only or All - this is important
We've added migrations to our xamarin forms project and ever since then we can't deploy it to an iOS device. It will run on the simulator fine but will fail with AOT errors on deploying to device.
It seems to be a fairly wide spread topic over the web but none of the ideas so far have made a difference. We're using EntityFrameworkCore v2.2.6 along with xamarin.forms v4.1.0.
I've tried adding the -v -v -v for more details on the build log but still just get:
Error Could not AOT the assembly '/Users/MyUser/Library/Caches/Xamarin/mtbs/builds/MyCompany.Mobile.iOS/8fcd0a31c7f6e1a671890e2462fe729f/obj/iPhone/Debug/mtouch-cache/3-Build/MyCompany.Data.Persistence.dll' MyCompany.Mobile.iOS
Any ideas what else I should try?
I haven't try these but it could fix your issue
IOS Build -> General -> and uncheck the option Incremental Build.
Disable LLVM.
Remove all unnecesary classes, methods from your MyCompany.Data.Persistence.dll so it wont generate heavy code.
Change Linking to Link All Assemblies
Xamarin.Android applications use a linker to reduce the size
The default value is SdkOnly
None: No linking will be attempted.
SdkOnly: Linking will be performed on the base class libraries only, not user's assemblies.
Full: Linking will be performed on base class libraries and user assemblies. For more details refer here.. Note: if you are facing an issue with linking such as
"GetAdditionalResourcesFromAssemblies" task failed unexpectedly. System.IO.FileNotFoundException: . Perhaps it doesn't exist in the Mono for Android profile?
then recheck your xamarin.Android project settings and set the below tag,
true
It Should Solve Your Problem.
I am trying to POST data using a REST API. The app used to run flawlessly, but now that I've added code to perform the POST, I'm getting a new error. Would anyone be able to help explain what's going wrong and suggest an alternative that would let me complete the POST request successfully?
Here's the error I get when I try to build the app with the linker enabled in the Release configuration:
Error The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Runtime.InteropServices.StandardOleMarshalObject' (defined in 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') from 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Runtime.InteropServices.StandardOleMarshalObject
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() GimcoIOT.Andriod
It looks like you might have added a reference to a desktop .NET assembly in your Xamarin.Android app. The System.Windows.Forms namespace is not available in the Xamarin.Android profile. (Even if the app builds successfully when you disable linking, it will in theory still fail at run time any time it tries to run code that references the System.Windows.Forms namespace.)
To solve this problem, you will want to remove the reference to the desktop .NET assembly from your Xamarin.Android project and ensure that all of your other referenced assemblies are compiled either against the Xamarin.Android profile or a supported PCL profile.
As mentioned in the documentation:
Xamarin.Android is not ABI compatible with existing assemblies compiled for a different profile. You must recompile your source code to generate assemblies targeting the Xamarin.Android profile (just as you need to recompile source code to target Silverlight and .NET 3.5 separately).
(Portable Class Libraries are the special exception to this rule.)
If you are currently using a type from the System.Windows.Forms namespace to perform the POST request, then you will need to switch to a different type. For example, one of the PostAsync() methods from System.Net.Http.HttpClient might work nicely.
I've got an error when I try to build a project (monodroid/mvvmcross).
This is the message error :
Error 37 The type 'Android.App.ListActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c4c4237547e4b6cd'.
Someone have an idea how to solve this problem ? This is strange because there wasn't this error before.
This error is located in MvxDialogActivityView.cs (cirrious.MvvmCross.Dialog.Droid)
I think your problem is that parts of your code is compiled against Xamarin.Android while others are compiled against Mono for Android.
See: http://forums.xamarin.com/discussion/1476/changes-to-assembly-strongnames-in-xamarin-android-4-6-0
You will need to recompile all parts of your application to target the same version of Xamarin's products.