適用於 Android 的 .NET 錯誤 XA4227

範例訊息

error XA4227: Architecture 'x86' doesn't match all marshal methods in architecture 'arm64-v8a'. Please see detailed MSBuild logs for more information.

Issue

當為多個 Android 架構建置時,每個架構產生的 marshal 方法必須一致。 此錯誤表示某架構的 marshal 方法與模板(第一)架構不符。

解決方案

確保所有目標架構參考相同的受管理型別與方法集合。 啟用詳細的 MSBuild 日誌(-v:diag),以精確判斷哪些 marshal 方法不同,然後調整專案,使所有架構產生相同的 marshal 方法集合。