範例訊息
error ADB0020: The package does not support the CPU architecture of this device.
問題
ADB0020 表示建置的 Android APK 未包含可運行在模擬器或裝置上的相符 Android 架構。
此訊息指出 adb (Android Debug Bridge) 回報INSTALL_FAILED_CPU_ABI_INCOMPATIBLE或INSTALL_FAILED_NO_MATCHING_ABIS錯誤。
adb 是 Android SDK 的一部分,由適用於 Android 的 .NET 內部用來與 Android 模擬器和裝置通訊。 從adb深入瞭解。
解決方法
設定 RuntimeIdentifier 或 RuntimeIdentifiers MSBuild 屬性,以包含 Android ABI 與裝置相符的 .NET RID:
-
android-arm封裝了armeabi-v7aABI。 -
android-arm64封裝了arm64-v8aABI。 -
android-x64封裝了x86_64ABI。
例如,以下 .NET 11 設定包含所有支援的 CoreCLR 架構:
<PropertyGroup>
<RuntimeIdentifiers>android-arm;android-arm64;android-x64</RuntimeIdentifiers>
</PropertyGroup>
Android NativeAOT 是實驗性版本,支援同樣的三種 RID。
實作注意事項
請注意,開放原始碼 https://github.com/dotnet/android 儲存庫中沒有任何東西會觸發ADB0020,因為像偵錯和「快速部署」這些功能是在專有的 Android .NET 擴充功能中實現的。