在Xamarin.Forms项目中,仅使用“ SDK程序集”进行编译时(对于“ SDK和用户程序集”相同),我收到一条错误消息(请参见错误消息)
我已经将“跳过程序集链接”设置为“ System; Acr; Splat”
为什么?预先谢谢你。
1。错误消息:
Severity Code Description Project File Line State of suppression
Error Unexpected error in the LinkAssemblies task:
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Drawing.Color' (defined in assembly 'Acr.UserDialogs.Interface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Splat, Version=1.6.2.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.Drawing.Color
bei Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
bei Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
bei MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
bei Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
bei Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
bei Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
bei MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
bei Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
bei Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
bei Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
bei Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
bei Mono.Linker.Steps.MarkStep.Initialize()
bei MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
bei Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
bei Mono.Linker.Pipeline.Process(LinkContext context)
bei MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
--- Ende der internen Ausnahmestapelüberwachung ---
bei Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() mInvoice.Android
2。 AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="XXXXXXXX" android:installLocation="auto" android:versionCode="75" android:versionName="5.2.2.2">
<uses-sdk android:targetSdkVersion="28" android:minSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.hardware.CAMERA" />
<uses-permission android:name="android.hardware.CAMERA.AUTOFOCUS" />
<application android:label="mInvoice" android:allowBackup="true" android:icon="@drawable/icon_30" android:theme="@style/Theme.mInvoice">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"></meta-data>
</provider>
</application>
</manifest>
答案 0 :(得分:0)
当范围不同于定义程序集时,通常 表示要转发类型。
您在Xamarin.Android应用程序项目中启用了application Linker
,并且Xamarin.Forms和Acr.UserDialogs.Interface
中转发类型之间的版本不匹配。基本上Acr.UserDialogs.Interface
是针对较旧版本的Forms进行编译的,那么您当前正在项目中使用它,并且如果程序集包含C#扩展名,这是一个非常普遍的问题。
您可以尝试禁用整个应用程序的链接或仅禁用Acr.UserDialogs.Interface
程序集的链接。
要仅禁用该程序集的链接,请编辑您的Android应用程序项目(.csproj
)并添加以下<AndroidLinkSkip>
:
<PropertyGroup>
<AndroidLinkSkip>Acr.UserDialogs.Interface</AndroidLinkSkip>
</PropertyGroup>
参考:Xamarin Android链接:AndroidLinkSkip
答案 1 :(得分:0)
尝试在Release config(Mac上的Visual Studio 2019)上构建时遇到相同的错误。
已将Xamarin.Android更新到9.4.1.0版本,问题已解决!
从UserDialogs存储库中报告了此问题的提示: https://github.com/aritchie/userdialogs/issues/654#issuecomment-531406106
希望有帮助。
答案 2 :(得分:-2)