我有Xamarin Forms应用程序(https://github.com/xamarinhq/app-evolve),当我在调试模式下运行时工作正常,但是当我尝试在发布模式下在发行版Xamarin.Android应用程序中编译时,它会抛出以下错误。
error MSB4018: The "LinkAssemblies" task failed unexpectedly.
error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void Android.Support.V7.View.WindowCallbackWrapper::n_OnProvideKeyboardShortcuts_Ljava_util_List_Landroid_view_Menu_I(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Int32)' in assembly: 'Xamarin.Android.Support.v7.AppCompat.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Views.KeyboardShortcutGroup
error MSB4018: at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
error MSB4018: at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
error MSB4018: at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
error MSB4018: at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
error MSB4018: --- End of inner exception stack trace ---
error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
error MSB4018: at Mono.Linker.Steps.MarkStep.Process()
error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)
error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
我的最低Android版本和目标Android版本如下。
最低和目标Android版本
答案 0 :(得分:0)
此API是在API 24中引入的,因此您需要至少编译API 24才能进行编译。您需要将<TargetFramework>
设置为7.0或更高才能包含此方法。
作为一般提示,您应该将<TargetFramework>
设置为您正在使用的支持库的相同主要版本。例如,如果您使用的是支持库的v26,那么您将针对API 26进行编译。