I'm trying to release a Xamarin.Forms application, but when I change to release in the configuration for the Android project and build I get the following error:
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Int32 Xamarin.Forms.Platform.Resource/String::ApplicationName' (defined in assembly 'Syncfusion.SfChart.XForms.Android, Version=13.2451.0.29, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 Xamarin.Forms.Platform.Resource/String::ApplicationName
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.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(DirectoryAssemblyResolver res)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
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() XamarinCRM.Android
The same error message occurred with me. I was able to solve it like this:
Right-click the Android Project > Properties > Android Options > Linker, and then choose the "None" option in the Linking property.
We suspect that there are some version conflicts between Syncfusion/Xamarin.Forms assemblies and we kindly request you to follow the below steps.
Update your Essential Studio for Xamarin to latest version (15.1.0.41) which can be downloaded from the following location.
Link: https://www.syncfusion.com/downloads/version-history/15_1_0_41
Update your Xamarin.Forms version to 2.3.3.180.
Please get back to us if you are still facing any issues.
Related
I have spent some weeks to create a prototype for my customer using the Blazor Webassembly hosting model. It has worked far above my expectations. Until now. Time for first deployment to real environment on Azure. I have configured PublishTrimmed=true in client and server project files. Is that needed in both projects?
Unfortunately the publish failed on the linking giving me these two errors:
"Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false."
"IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues"
In the dialog I am referred to a tmp file having this content:
"System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details."
The output window includes this section:
Fatal error in IL Linker
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'input')
at System.Text.RegularExpressions.ThrowHelper.ThrowArgumentNullException(ExceptionArgument arg)
at System.Text.RegularExpressions.Regex.Matches(String input)
at Mono.Linker.Steps.MarkStep.MarkTypeWithDebuggerDisplayAttribute(TypeDefinition type, CustomAttribute attribute)
at Mono.Linker.Steps.MarkStep.MarkTypeSpecialCustomAttributes(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet1 typesAlreadyVisited) at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet1 typesAlreadyVisited)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
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.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
What can I do? I have really recommended Blazor to my colleagues. I would be ashamed to tell them we need to skip the trimming and publish an application that will give the customers a download size of 9 MB!!!!
Is the trimming just an empty promise or does it actually work in real applications? Can I do something to detect the crucial problem? The error hints are not really helpful. I don't mind reporting an issue, but I have no meaningful details to include in the report.
I get this error when i typing add migration. The ApplicationDbContext exists in another project while migration file exist in the web application project.
If I remember right it has worked before but now it stopped to work.
I have tried restart visual studio, run it as administrator. reinstall EF 6.11, 6.13 and 6.20.
Visual Studio Version 15.8.5, Build Tool 15.1
The migration exists in the startup project and the package manager is also set on the startup project.
I have even tried to repair Visual Studio and after I also tried uninstall and then install but nothing works.
I tried the the solution where I edit devenv.exe.config which did not work
https://github.com/aspnet/EntityFramework6/issues/382
add-migration AddedUserFax
System.TypeInitializationException: The type initializer for 'Company.SoftwareX.Contexts.ApplicationDbContext' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Company.SoftwareX.Database.Contexts.ApplicationDbContext..cctor()
--- End of inner exception stack trace ---
at Company.SoftwareX.Database.Contexts.ApplicationDbContext..ctor() in C:\Projects\Visual Studio\Project\Company.SoftwareX.Database\ApplicationDbContext.cs:line 110
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance()
at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The type initializer for 'Company.SoftwareX.Database.Contexts.ApplicationDbContext' threw an exception.
The answer to this question is to not have a static constructor in the DbContext or other static methods in constructor that is required to run before a new instance is created.
The big clue is in the stack-trace, System.TypeInitializationException: The type initializer for... This indicates that static properties/constructors (that, by contract, must run before any instances can be new-ed up) have thrown errors.
- Spender
I am trying to build Xamarin.Android(Native) project in release mode but am not able to build the project. Below is the error that I am getting.
Severity Code Description Project File Line Suppression State Error The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006:
Could not resolve reference to 'Android.App.Job.JobServiceEngine'
(defined in assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null') with scope 'Mono.Android,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
When the scope is different from the defining assembly, it usually
means that the type is forwarded. ---> Mono.Cecil.ResolutionException:
Failed to resolve Android.App.Job.JobServiceEngine at
Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference
reference) 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.MarkType(TypeReference reference) at
MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
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, ILogger logger,
LinkContext& context) at
Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver
res) --- End of inner exception stack trace --- at
Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception
innerException, String message, Object[] args) at
Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver
res) at Xamarin.Android.Tasks.LinkAssemblies.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
I also tried solution mentioned in this SO post but still the same error.
We have a Xamarin.Forms android and ios app which has been performing well for a number of years now. The latest version has been in prod since early 2017, and has had very few crashes. Until recently!
One of our android clients started getting exceptions when connecting to our ServiceStack powered API service. Now our API service hasn't been changed since the App deployment (Jan 2017), and we've just started getting these errors in Dec 2017.
The details from the app logging on their device reveal the following.
Exception: The type initializer for 'System.AndroidPlatform' threw an exception.StackTrace: at System.Net.WebProxy.CreateDefaultProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <10a067eff09446018662189377d200e9>:0
at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <10a067eff09446018662189377d200e9>:0
at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor (System.Uri)
at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <10a067eff09446018662189377d200e9>:0
at ServiceStack.PclExport.CreateWebRequest (System.String requestUri, System.Nullable`1[T] emulateHttpViaPost) [0x00000] in <0c56e395a4c44995b59b57d9e7ca7331>:0
at ServiceStack.ServiceClientBase.PrepareWebRequest (System.String httpMethod, System.String requestUri, System.Object request, System.Action`1[T] sendRequestAction) [0x0004e] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.SendRequest (System.String httpMethod, System.String requestUri, System.Object request) [0x00014] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Send[TResponse] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00075] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (System.String relativeOrAbsoluteUrl) [0x00000] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (ServiceStack.IReturn`1[T] requestDto) [0x00012] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at [OUR APP].PCL.Services.Agent.IsAwake () [0x00013] in <cb1d96a8f02e4d9f92152b248e31ee23>:0
Source: System
Has Inner Exceptions: True
Inner Exception 1: Couldn't bind to method 'CertStoreLookup'.
StackTrace: at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, System.Reflection.BindingFlags bflags, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x000f9] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x00014] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.AndroidPlatform..cctor () [0x0002d] in <10a067eff09446018662189377d200e9>:0
Source: mscorlib
Has Inner Exceptions: False
25/01/18 11:01:19 IsAwake The type initializer for 'System.AndroidPlatform' threw an exception. Endpoint http://OURENDPOINT/
25/01/18 11:01:18 Sync Started
I have been able to reproduce this error, but only in a release build. It all works fine in DEBUG mode, when using the Shared Runtime Framework. So it's leading me to think that the release build packaging of Android is removing something that Android requires, but I can't for the life of me figure out what it is.
Version Info
VS2017 15.5.6
Xamarin 4.8.0.760
Xamarin.Android SDK 8.1.5.0
Xamarin.Forms v1.5.0.6447 (in PROD)
ServiceStack.Client (PCL proj via NuGet) 4.0.40 (in PROD)
Installed SDK's
8.0.0(26), 7.1.1(25), 7.0(24), 6.0(23), 5.01(21), 4.4.2(19),
Build Config
Target Framework: 6.0 (v23)
Minimum SDK: 4.0.3 (v15)
**DEBUG**
Use Shared Runtime : true
Use Fast Deploy : false
Linking: SDK Assemblies only
**RELEASE**
Use Shared Runtime : false
Use Fast Deploy : false
Linking: none
I've been trying many things..
I've updated the Target Framework to 7.1 with minimum to 5.0, removed all Xamarin and ServiceStack references, and then installed the new ones that target the framework level.
Everything always works in DEBUG, but not in RELEASE.
Would greatly appreciate any assistance anyone could supply..
TIA.
EDIT
After performing the steps suggested by #mahmoud-kamel, I get the following errors for the RELEASE build.
Severity Code Description Project File Line Source Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void Android.Support.V4.App.FragmentActivity::n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(System.IntPtr,System.IntPtr,System.Int32,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.Android.Support.Fragment.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
at Mono.Linker.Steps.MarkStep.Process()
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(DirectoryAssemblyResolver res)
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() [OUR APP].DroidApp C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1696 Build
This turned out to be a mismatch of assemblies referenced by the project.
After looking at the internals of the System.dll's in the bin/debug and bin/release folders, and comparing those of a new project from VS template, we were able to determine that after the project was upgraded to use the latest SDK, MSBuild wasn't retrieving the SYSTEM.dll from the correct ReferenceAssemblies folder location.
Doing a search for "ReferenceAssemblies" on my pc brings up about 4 locations!
The correct location (on my pc) is the following folder, with the Android version number folder (eg. "v8.0".
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\
I hope this helps someone and saves them the hours I spent on this!
put Target framework to the latest and the minimum is version 16
right click on Android project then go to options make sure that Release mode in linker tab and choose link SDK Assemblies only
save all changes then clean all solution , close the project and visual studio
go to folder of project then delete bin, obj folders
open visual studio , and try to start deploy project in release mode
I created xamarin traditinal android project 2-3 months ago but I need update this project but I'm getting an error;
Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Void Android.App.Activity::OnMultiWindowModeChanged(System.Boolean)' (defined in assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnMultiWindowModeChanged(System.Boolean)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.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(DirectoryAssemblyResolver res)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
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() MHG.SozumSana.UI
error XA2006: Could not resolve reference to 'System.Void Android.App.Activity::OnMultiWindowModeChanged(System.Boolean)' (defined in assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
Please check the onMultiWindowModeChanged API, it is added in API level 24. As #MCZ suggested, this is a known issue.
You can try to change the settings like this:
Besides, Android 7.0 needs Android JDK 1.8, I think you may have installed it since you can build your app earlier, please check the Java Development Kit Location in Tools -> Options-> Xamarin of your VS2017.
While using visual studio check linker property it mostly set to "None" that you have to change it.
And check TargetAndroidVersion. (In the config GUI, this is entitled "Compile using Android version:")