Andr谩s T贸th‘s professional blog
banditoth.net

Hey there 馃憢, I’m banditoth a .NET MAUI developer from Hungary.
I write about software development with .NET technologies.

You can find me on:
LinkedIn | Github | StackOverflow | X / Twitter | Threads

Debug .NET MAUI Android apps with Android work profile

An Android Work Profile is a feature that allows you to separate work apps and data from personal apps and data on the same device. This is particularly useful for maintaining privacy and security in a corporate environment. However when you are developing an app for your company, who’s got these configurations on their mobile devices, you might find yourself in a tricky solution, because VS Code simply installs the app on the workprofile and on the normal profile aswell, but only can run with debug on the normal profile without any configuration.

Get the users of the Android device

To list users on an Android device using ADB (Android Debug Bridge), you can use the following command:

adb shell pm list users

This command will display a list of users on the device, including their user IDs.

For example, the output might look something like this:

Users:
    UserInfo{0:Owner:13} running
    UserInfo{10:Work:30} running

Configure the .csproj to launch the app on work profile

Insert the following line within the聽<PropertyGroup>聽section of your .csproj file:

<AndroidDeviceUserId>10</AndroidDeviceUserId>

This attribute specifies the user ID for the Android Work Profile. The user ID聽10聽is commonly used for work profiles, but you should verify this for your specific setup.

Last but not least: Hit F5 and Run your project 馃檪

Remark: This solution is only working in Visual Studio for Windows, and Visual Studio Code on mac.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.