Search code examples
androidxamarinxamarin.formsxamarin.android

SIGABRT when running a Xamarin.Forms app on Android 12


I'm working on a Xamarin.Forms application, which runs fine on all Android versions up to and including 11.

However, I was asked to target Android 12 with the app. So I updated all NuGet packages to the latest, installed JDK11, set it in Projects > Android > Locations. I changed the "compile with" SDK to Android 12.0 (S) and "Target Android Version" to Android 12.0 in the Android project settings.

The application compiles fine, and runs properly on Android 11 emulator. But once I deploy to Android 12 emulator, Visual Studio shows "Failed to attach the debugger" error, and application crashes immediately after native splash. Logcat has this to show:

2021-12-01 17:41:51.888 17289-17289/com.my.project W/monodroid-gc: GREF GC Threshold: 46080
2021-12-01 17:41:53.132 17289-17289/com.my.project W/com.my.project: Attempt to remove non-JNI local reference, dumping thread
2021-12-01 17:41:54.382 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libEGL_emulation.so
2021-12-01 17:41:54.392 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
2021-12-01 17:41:54.400 17289-17321/com.my.project D/libEGL: loaded /vendor/lib64/egl/libGLESv2_emulation.so
2021-12-01 17:41:58.663 17289-17289/com.my.project W/com.my.project: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2021-12-01 17:41:58.664 17289-17289/com.my.project W/com.my.project: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2021-12-01 17:42:09.395 17289-17289/com.my.project I/com.my.project: Explicit concurrent copying GC freed 3212(948KB) AllocSpace objects, 2(40KB) LOS objects, 49% free, 2495KB/4990KB, paused 430us total 10.736ms
2021-12-01 17:42:18.466 17289-17336/com.my.project E/app_process64: * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/utils/mono-context.c:474, condition `fpctx->head.magic == FPSIMD_MAGIC' not met
2021-12-01 17:42:18.466 17289-17337/com.my.project E/app_process64: * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/utils/mono-context.c:474, condition `fpctx->head.magic == FPSIMD_MAGIC' not met
2021-12-01 17:42:18.466 17289-17335/com.my.project E/app_process64: * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/utils/mono-context.c:474, condition `fpctx->head.magic == FPSIMD_MAGIC' not met
2021-12-01 17:42:18.472 17289-17335/com.my.project A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17335 (Thread-3), pid 17289 (com.my.project)
2021-12-01 17:42:18.584 17340-17340/? I/crash_dump64: performing dump of process 17289 (target tid = 17335)
2021-12-01 17:42:18.865 17340-17340/? A/DEBUG: pid: 17289, tid: 17335, name: Thread-3  >>> com.my.project <<<
2021-12-01 17:42:18.983 336-336/? I/Zygote: Process 17289 exited due to signal 6 (Aborted)
2021-12-01 17:42:18.997 1292-2303/? I/ActivityManager: Process com.my.project (pid 17289) has died: fg  TOP 
2021-12-01 17:42:19.041 1292-1772/? I/libprocessgroup: Successfully killed process cgroup uid 10157 pid 17289 in 44ms
2021-12-01 17:42:19.082 1292-1722/? W/ActivityManager: setHasOverlayUi called on unknown pid: 17289

I see exactly the same ouput when compiling in Release mode.

If I create a blank Xamarin.Forms application, and re-target it for Android 12, it launches properly, albeit Visual Studio still fails to attach the debugger.

If I run a native Android app, which also targets Android 12, on the same emulator, it runs correctly.

I'm not entirely sure where to go from here. Our application is large, and has been in development for several years now. At the moment I'm trying to remove our external dependencies one-by-one and see if any of them might be the cause, but it's a tedious process, and I'd love to know if there's a better way.


Solution

  • The application began launching after I did the following:

    • Removed a Java.Interop reference from the Android project References.
    • Ticked x86_64 support at Android Project > Options > Android Build > Advanced. For some reason supported architectures checkboxes get randomly checked and unchecked in our P4 history, and I don't think anybody on our team did that deliberately.