android: Debug deploy fails if EmbedAssembliesIntoApk=true and AndroidSupportedAbis does not include arm64-v8a

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

Visual Studio Enterprise 2022 for Mac Version 17.3.8 (build 5) AND Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.3.6

Description

My team has sample apps for a SDK (set of nugets) for classic Xamarin.Android that we distribute that embed native libraries (.so files) for armeabi-v7a but not arm64-v8a, so we build them with <AndroidSupportedAbis>armeabi-v7a;x86;x86_64</AndroidSupportedAbis>. We do not include “arm64-v8a” in that set. The apps run on modern ARM64 Android devices just fine.

This combination has worked well in both VS for Windows and Mac 2019 when deploying to a debugger with “fast assembly deployment” disabled. With most versions of VS, fast assembly deployment works, but older versions had issues, so we began disabling fast assembly deployment in the sample apps, leaving it to people who use our nugets to do what they want in their customized apps.

In Visual Studio 2022 (latest releases for Windows and Mac) I see that these apps fail to deploy through the debugger with “fast assembly deployment” disabled. I can replicate this behavior with a simple Xamarin.Android template project where I disable fast assembly deployment and remove “arm64-v8a” from the AndroidSupportedAbis .csproj property.

P.S I could create tickets on developercommunity.visualstudio.com, but given that the issue appears on both Windows and Mac, I expect that tooling in Xamarin.Android is shared and it makes sense to go straight here .

Steps to Reproduce

  1. Create a new app in VS for Mac: Android->App->General
  2. Remove “arm64-v8a” from AndroidSupportedAbis in the .csproj.
  3. See that the app deploys.
  4. Disable “fast assembly deployment” (setting EmbedAssembliesIntoApk=true in the .csproj file).
  5. See that the app does not deploy.

Did you find any workaround?

Enabling fast deployment is a workaround. But it would be nice to have two working ways to deploy, in case fast assembly deployment breaks.

Relevant log output

Application output window:

Forwarding debugger port 8862
Detecting existing process
> am start -a "android.intent.action.MAIN" -n "com.companyname.abideploytest/crc6478e4fb5c678bec2f.MainActivity"
> Starting: Intent { act=android.intent.action.MAIN cmp=com.companyname.abideploytest/crc6478e4fb5c678bec2f.MainActivity }

[Zygote] Unable to open libbeluga.so: dlopen failed: library "libbeluga.so" not found.
[e.abideploytes] Late-enabling -Xcheck:jni
[e.abideploytes] Unquickening 17 vdex files!
[e.abideploytes] Using default instruction set features for ARM CPU variant (cortex-a9) using conservative defaults
[Perf] Connecting to perf service.
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[monodroid] Creating public update directory: `/data/user/0/com.companyname.abideploytest/files/.__override__`
[e.abideploytes] Attempt to remove non-JNI local reference, dumping thread
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8862,server=y,embedding=1
[monodroid-assembly] Failed to load managed assembly 'mscorlib.dll'. Internal error
[monodroid-assembly] open_from_bundles: failed to load assembly mscorlib.dll
[mono] The assembly mscorlib.dll was not found or could not be loaded.
[mono] It should have been installed in the `/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/sdks/out/android-armeabi-v7a-release/lib/mono/2.1/mscorlib.dll' directory.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 52 (21 by maintainers)

Most upvoted comments

@grendello , @dellis1972 We still cannot debug our (xamarin-android 11) app using VS2022. Should the known issues above be fixed in the latest version of VS2022 + xamarin-android 11?

@grendello, @dellis1972 Would one of you guys mind clarifying what needs to be in place for us to be able to debug again? Is this just a VS2022 update on the horizon, or is the fix only going to apply to .NET 7/8? I’m hoping the former, because my team made an attempt to upgrade to .NET 7 a few months ago and found that it’s extremely difficult to upgrade this without also upgrading to .NET MAUI, which (at the time) seemed incredibly buggy and unstable.

@grendello Did we fix this mscorlib loading bug? I can’t see the fix anywhere. Was it in our stuff or upstream?

It was kind of on both sides. It was assumption about MonoVM behavior on our side, and a bug regarding that behavior on MonoVM side. https://github.com/dotnet/runtime/pull/80949 was the fix.

@Adam-- Tried with bundle and received same error. Tried with Fast Deployment and bundle which netted a different error. But yes, if I try with apk and Fast Deployment I get…

Install FastDeployment Tools XA0136: The ‘run-as’ command failed with 'run-as: Package ‘com.lathem.payclock’ has corrupt installation '. The currently installation of the package in corrupt. Please manually uninstall the package from all the users on device and try again. If that does not work you can disable Fast Deployment. Fast Deployment can be disabled in the Visual Studio project property pages or edit the project file in a text editor and set the ‘EmbedAssembliesIntoApk’ MSBuild property to ‘true’.

Done executing task “FastDeploy” – FAILED.

Don’t suppose we have any idea how long it will be before the fix for the original issue makes it into VS 2022 do we? Really don’t want to have to work without being able to debug for very long.

The PR for the debugging bits (closed source) has been merged and I hope it fixes it for you case. I am hoping it will make it into the first .net 8 Preview. I’m not entirely sure what the schedule is for the release though.

so this is weird. arm64-v8a was not in the list of supported package but some native assemblies are being included in the apk.


                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/armeabi-v7a/libmono-native.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/x86/libmono-native.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/arm64-v8a/libmono-native.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/x86_64/libmono-native.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/armeabi-v7a/libxamarin-debug-app-helper.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/x86/libxamarin-debug-app-helper.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/arm64-v8a/libxamarin-debug-app-helper.so
                       /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/lib/x86_64/libxamarin-debug-app-helper.so
                       obj/Debug/android/bin/classes.dex
                       obj/Debug/app_shared_libraries/armeabi-v7a/libxamarin-app.so
                       obj/Debug/app_shared_libraries/x86/libxamarin-app.so
                       obj/Debug/app_shared_libraries/x86_64/libxamarin-app.so

So the libmono-native.so is including the arm64-v8a version. So this might be a case where its trying to mix 32bit and 64bit libraries. I’ll try to repo here locally and see if we can figure out why we are including the 64 bit ones when we shouldn’t be.

Thanks, @dellis1972. I was using a Honeywell CT45. Dumping out some of the properties from the device’s BuildInfo, I see:

Supported32BitAbis: [armeabi-v7a,armeabi], Supported64BitAbis: [arm64-v8a], SupportedAbis: [arm64-v8a,armeabi-v7a,armeabi]

Here is a diff using your example.csproj as the base, and the project I ended up with as the destination: example-diff.txt. The only interesting differences that I notice are that I’m including x86 and x86_64 support. Removing that doesn’t change behavior, though.

Here is the test app source that I’m using (a tiny git repo, shows the template-generated solution, followed by the edits): abideploytest.zip