Skip to content

vsdbg Android debug adapter ignores AndroidDeviceUserId when launching activity — am start missing --user flag #10841

@t4e-dev

Description

@t4e-dev

Android framework version

net10.0-android

Affected platform version

VS 2026

Description

When AndroidDeviceUserId is set in the main csproj file ( MAUI App ), the MSBuild targets correctly use it for deployment (FastDeploy/Install) but Visual Studio's vsdbg debug adapter does not pass --user to the am start command during F5 debugging. This makes it impossible to debug apps deployed to an Android Work Profile (managed profile, typically User 10).
Environment:
• Visual Studio 2026 (latest)
• .NET 10, net10.0-android (Microsoft.Android.Sdk.Windows 36.1.2)
• Physical device: Samsung SM-A546B with Work Profile (User 10)
• 10 set in main MAUI csproj
Expected behavior:
vsdbg should include --user 10 in the am start command, consistent with how RunActivity in Xamarin.Android.Common.Debugging.targets already passes UserID="$(AndroidDeviceUserId)" and how Xamarin.Android.Common.Debugging.props already computes:

--user $(AndroidDeviceUserId)

Actual behavior:
VS debug output shows the launch command without --user:

am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity"
Error type 3
Error: Activity class {de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity} does not exist.

The app is correctly installed for User 10 (verified via adb shell pm list packages --user 10), but am start without --user 10 searches User 0 where the package does not exist.
What works correctly:
• ✅ FastDeploy / Install target respects AndroidDeviceUserId=10 (deploys to User 10)
• ✅ RunActivity MSBuild task passes UserID="$(AndroidDeviceUserId)" correctly
• ✅ LaunchFlags property is computed correctly in Debugging.props
• ✅ Manual launch via adb shell am start --user 10 -n ... works
• ❌ vsdbg constructs its own am start without reading AndroidDeviceUserId or LaunchFlags

Impact:
This blocks F5 debugging entirely for enterprise apps deployed to Android Work Profiles. There is no workaround within Visual Studio — Attach to Process does not offer an Android transport for .NET MAUI projects, and launchSettings.json commandLineArgs are not forwarded to am start.
Suggested fix:
vsdbg's Android launch logic should read AndroidDeviceUserId (or LaunchFlags) from the MSBuild project evaluation and append --user to the am start invocation, matching the behavior already implemented in RunActivity and FastDeploy.

Steps to Reproduce

  1. Set up an Android device with a Work Profile (User 10)
  2. Add 10 to the application CreditCard.Provider.csproj
  3. Press F5 in Visual Studio
  4. Observe: Deploy succeeds, but launch fails with Activity class does not exist

Did you find any workaround?

With Visual Studio 2026 and .NET9 everything works as expected. Deploy and Debug both works with profile / user 10.

No response

Relevant log output

tarting vsdbg debug session for project 'C:\repos\xxx\src\frontend\core\TCPOS.DroidPos\TCPOS.DroidPos.csproj'...
> am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity"
> Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity }
Error type 3
Error: Activity class {de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity} does not exist.

error: Error: Device could not find component named: de.zucchetti.db.moka/crc643aba18955c58aa24.CoordinatorActivity
The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.need-attentionA xamarin-android contributor needs to review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions