Skip to content

Debug deploy fails if EmbedAssembliesIntoApk=true and AndroidSupportedAbis does not include arm64-v8a #7521

Closed as not planned

Description

@gkarabin

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 armeabi-v7a;x86;x86_64. 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.

Activity

  1. added
    Area: App Runtime
    needs-triage
    on Nov 2, 2022
  2. added
    Area: App+Library Build
    and removed
    Area: App Runtime
    on Nov 2, 2022
  3. removed
    needs-triage
    on Nov 2, 2022
  4. added this to the Under Consideration milestone on Nov 2, 2022
  5. dellis1972 commented on Nov 2, 2022

    @dellis1972
    Contributor

    @gkarabin

    Out of interest what kind of device are you deploying too?

    So the way this works is , with Fast Deployment on we ignore the AndroidSupportedAbis and look at the device which is being targeted. We then only include the assemblies for that device.

    With Fast Deployment off, you end up with only the ABI's in the AndroidSupportedAbis list. So if you are deploying to a device which does support the abi's you have targeted at all then you should get a deployment error. Not a runtime one.
    I tried to repo this using the steps outlined above and it works here some there must be some other different.

    Here is the csproj https://gist.github.com/dellis1972/68d33b288753408970cffdda4e978a0e. Can you compare this with your example and see if you can spot the changes? Or upload the example. Also if you can let us know what device you are deploying too that would help us track this down too.

  6. added
    need-info
    on Nov 2, 2022
  7. gkarabin commented on Nov 3, 2022

    @gkarabin
    Author

    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

  8. ghost removed
    need-info
    on Nov 3, 2022
  9. 42 remaining items

  10. jlinker7 commented on Feb 21, 2023

    @jlinker7

    I will try to create a new issue when I get a chance, but if your curiosity gets the better of you before then, here is what was produced...
    msbuild.zip

  11. jlinker7 commented on Feb 22, 2023

    @jlinker7

    @dellis1972 new issue opened here...
    #7821

  12. putto72 commented on Apr 3, 2023

    @putto72

    I'm experiencing the same problem, Visual Studio 2022 version 17.5.33516.290. If I enable Fast Debug, I get the run-as problem. If I disable Fast Debug, I get mscorlib problem. I cannot debug anymore using VS 2022! When will this problem be fixed?

  13. dellis1972 commented on Apr 3, 2023

    @dellis1972
    Contributor

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

    @putto72 did run-as work before on the same device? I'd be interested in knowing if we regressed in that area some how?
    If that is the case please provide additional data as outlined here https://github.com/xamarin/xamarin-android/wiki/Diagnose-Fast-Deployment-Issues

  14. putto72 commented on Apr 3, 2023

    @putto72

    @putto72 did run-as work before on the same device? I'd be interested in knowing if we regressed in that area some how? If that is the case please provide additional data as outlined here https://github.com/xamarin/xamarin-android/wiki/Diagnose-Fast-Deployment-Issues
    Unfortunately I was using Visual Studio 2019 before, so I can't tell you if it worked before...

  15. dellis1972 commented on Apr 3, 2023

    @dellis1972
    Contributor

    Unfortunately I was using Visual Studio 2019 before, so I can't tell you if it worked before...

    Did Fast Deployment work on the same device in VS 2019?

  16. grendello commented on Apr 3, 2023

    @grendello
    Contributor

    @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. dotnet/runtime#80949 was the fix.

  17. bobbydharrell commented on Apr 3, 2023

    @bobbydharrell

    I see you have a fix merged in, when can we get our hands on it?

  18. jfichtner commented on May 10, 2023

    @jfichtner

    @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.

  19. jfichtner commented on Jul 12, 2023

    @jfichtner

    @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?

  20. Adam-- commented on Jul 17, 2023

    @Adam--

    To be honest, I'm not sure how all the pieces and versions fit together, but I was able to update to Visual Studio 2022 version 17.6.5 (I last tried version 17.5.5) and the Fast Deployment workaround now works. I still have the original "Failed to load managed assembly 'mscorlib.dll'" error with Fast Deployment disabled, but it's exciting to be able to use VS 2022 now!

    The only thing I could find in the release notes were the following from 17.6.0

    .NET MAUI
    • Updates .NET MAUI to 7.0.86 (SR6), see https://aka.ms/dotnet-maui-releases for release notes.
    • Updates to .NET for Android 33.0.46
    • Updates to .NET for iOS 16.4.7060

  21. removed
    need-attention
    on Mar 20, 2024
  22. jpobst commented on May 17, 2024

    @jpobst
    Contributor

    With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant.

    If this still persists in .NET 8+, please open a new issue with updated information based on net8.0-android or greater. Please include a link to this issue for context.

  23. locked and limited conversation to collaborators on Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library Build

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions