Fix AndroidDeviceUserId not passed to am start on debug/run#10861
Open
Fix AndroidDeviceUserId not passed to am start on debug/run#10861
am start on debug/run#10861Conversation
…rt commands Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix AndroidDeviceUserId issue in debug after .NET10 migration
Fix AndroidDeviceUserId not passed to Feb 26, 2026
am start on debug/run
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes launching on non-primary Android users (e.g., Android Enterprise work profiles) by propagating AndroidDeviceUserId into all relevant am start invocations across legacy and SDK-style run paths.
Changes:
- Add conditional
--user $(AndroidDeviceUserId)toStartAndroidActivityand other MSBuild launch paths (includingdotnet runand logging-based runs). - Add a new
--userCLI option toMicrosoft.Android.Runand forward it toam start. - Add a device integration test asserting
--userappears in the generatedam startcommand.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs | Adds an integration test intended to verify --user is included in am start. |
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Application.targets | Updates StartAndroidActivity to include --user when AndroidDeviceUserId is set. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets | Threads --user through all three launch paths (tool-based run, direct adb fallback, and RunWithLogging). |
| src/Microsoft.Android.Run/Program.cs | Adds --user option and appends it to am start arguments. |
....Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets
Show resolved
Hide resolved
....Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Application.targets
Show resolved
Hide resolved
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

StartAndroidActivitytarget inXamarin.Android.Application.targetsto include--user $(AndroidDeviceUserId)when set_AndroidComputeRunArgumentstarget inMicrosoft.Android.Sdk.Application.targetsto include--userfor both Microsoft.Android.Run and direct adb pathsRunWithLoggingtarget inMicrosoft.Android.Sdk.Application.targetsto include--user--usercommand-line option toMicrosoft.Android.Run/Program.cs--usertoam force-stopinStopApp()for consistent behavior on work profilesAndroidDeviceUserIdis passed toam startcommandOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.