Xamarin-android: Deployment fails to x86 emulator even though x86 ABI is selected

Created on 8 Dec 2020  路  7Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Create a Xamarin.Forms project that includes an Android build
  2. Have an Android x86 emulator. I'm using a Pixel 3a XL, Pie 9.0, x86
  3. Have all ABIs selected and try to debug the app and it will fail, complaining that x86 is not selected (even though it is)

My app has mostly default Android settings, but Fast Deployment is disabled:

image

All ABIs selected:

image

CSPROJ has this empty tag (which is what you get when all ABIs are selected):

    <AndroidSupportedAbis>
    </AndroidSupportedAbis>

When I try to debug the app, this is in the Xamarin Diagnostics window:

[D:RunShellCommand]:      emulator-5554 "pm" "path" "com.android.shell"
[I:]:                     Android: ABI mismatch check - `armeabi-v7a;arm64-v8a`, `x86`
[E:]:                     Android ABI mismatch. You are deploying an app supporting 'armeabi-v7a;arm64-v8a' ABIs to an incompatible device of ABI 'x86'. You should either create an emulator matching one of your app's ABIs or add 'x86' to the list of ABIs your app builds for.

If I selected any other combination of ABIs that includes x86, for example <AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>, then it works fine. It's just when _all_ are selected that it fails on deployment.

I suspect this might be that when you select all the ABIs then it saves an empty list as opposed to A,B,C,D, whereas if you select a subset of ABIs then it saves the exact list A,B.

Expected Behavior

If I have x86 ABI selected, it should run on an x86 Android emulator, regardless of any other ABIs that I have selected.

Actual Behavior

I can only run x86 if I de-select an arbitrary other ABI.

Version Information

Microsoft Visual Studio Enterprise 2019 Preview
Version 16.9.0 Preview 1.0
VisualStudio.16.Preview/16.9.0-pre.1.0+30709.64
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Mono Debugging for Visual Studio   16.9.6 (8833fbf)
Support for debugging Mono processes with Visual Studio.

Xamarin   16.9.000.96 (d16-9-p1@f43214e)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   11.1.99.168 (master/71dc718)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: be2226b
    Java.Interop: xamarin/java.interop/master@ac914ce
    ProGuard: Guardsquare/proguard/v7.0.0@84e8560
    SQLite: xamarin/sqlite/3.32.1@1a3276b
    Xamarin.Android Tools: xamarin/xamarin-android-tools/master@1878e43


Xamarin.iOS and Xamarin.Mac SDK   14.7.0.166 (d91932dcd)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Log File

N/A

App+Library Build

Most helpful comment

I think the entire problem boils down to this:

    <AndroidSupportedAbis>
    </AndroidSupportedAbis>

If $(AndroidSupportedAbis) is blank and you are not using Fast Deployment, it defaults to:

https://github.com/xamarin/xamarin-android/blob/3433984571dc60c31a0b9996d20b0f09dcce801a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L229

Which won't work on an x86 emulator. Fast Deployment would work, because it detects the attached device/emulator and uses the single ABI.

@tondat or @joj is there some logic in the IDE that writes an empty property? I think it could probably just emit all four ABIs when all four are selected?

All 7 comments

This is actually more of a Area: App+Library Build issue instead of App Runtime. The problem happened when I _tried_ to run the app (but couldn't), not _while_ it was running.

I think the entire problem boils down to this:

    <AndroidSupportedAbis>
    </AndroidSupportedAbis>

If $(AndroidSupportedAbis) is blank and you are not using Fast Deployment, it defaults to:

https://github.com/xamarin/xamarin-android/blob/3433984571dc60c31a0b9996d20b0f09dcce801a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L229

Which won't work on an x86 emulator. Fast Deployment would work, because it detects the attached device/emulator and uses the single ABI.

@tondat or @joj is there some logic in the IDE that writes an empty property? I think it could probably just emit all four ABIs when all four are selected?

@jonathanpeppers this seems spot on. The empty tag seems to be inconsistently handled between the VS for Windows build options and between the Android targets in MSBuild.

I am also seeing this issue, when Fast Deployment is disabled.

Ran into this problem today and Google brought me here. Would be nice if it got fixed.

Same for me. Ticked them off and back on as cannot run in the emulator. Only happens in release mode for me.

I had to edit the droid csproj file and add this to all the configuration types

<AndroidSupportedAbis>armeabi-v7a;x86_64;arm64-v8a;x86</AndroidSupportedAbis>

I had <AndroidSupportedAbis /> for two and the third was <AndroidSupportedAbis></AndroidSupportedAbis>

Microsoft Visual Studio Enterprise 2019
Version 16.9.3
VisualStudio.16.Release/16.9.3+31129.286
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Microsoft Visual Studio Tools for Applications 2019 00435-60000-00000-AA255
Microsoft Visual Studio Tools for Applications 2019

C# Tools 3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Mono Debugging for Visual Studio 16.9.7 (df23ba6)
Support for debugging Mono processes with Visual Studio.
Xamarin 16.9.000.273 (d16-9@1bba9e0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.9.0.316 (remotes/origin/d16-9@fdbf64026)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.9.68 (8e9b569)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 11.2.2.1 (d16-9/877f572)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@54f8c24
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.34.1@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11

I brought this up again internally. /cc @tondat @joj

Was this page helpful?
0 / 5 - 0 ratings