4

I've just started developing with Android Enterprise and need to deploy an app in work profile.

My policy (see below) allows installation of apk with debug build variant. Starting a debug session via Android Studio now install the app both in private and work profile which means the policy is active on the work profile. However,the debug session always connects to the app in private profile.

Is it possible to start the debug session directly to the app instance on the work profile?

I've additionally tried with user flag:

adb shell am start -n "com.siemens.fileshare/com.siemens.fileshare.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D -W --user 10

The connection, however, times out.

Here is my policy:

{
  "name": "enterprises/some123/policies/policy1",
  "version": "11",
  "applications": [
    {
      "packageName": "com.google.samples.apps.iosched",
      "installType": "FORCE_INSTALLED"
    },
    {
      "packageName": "com.mycompany.myapp",
      "installType": "AVAILABLE"
    }
  ],
  "debuggingFeaturesAllowed": true
}
tuxdost
  • 133
  • 1
  • 14

1 Answers1

3

Here is how it worked for me.

Attach a mobile phone with work profile to the PC and make sure USB debugging is available.

Build a fresh debug.apk

Following commands have to be entered in Terminal of Android Studio.

a) Check users tux@C:>adb shell pm list users

Users:

UserInfo{0:owner:13} running UserInfo{12:Work profile:30} running

b) Install App tux@C:>adb install --user 12 "c:\dev\source\test\ShareXml\app\build\outputs\apk\debug\app-debug.apk"

c) Start the debugger tux@C:> adb shell am start --user 12 -n "com.mycompany.myapp/SomeActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D

d) Connect the process manually to the debugger in Android Studio (see the attached screen shot) enter image description here

This post helped me solve the issue: Debugging with Android Studio stuck at "Waiting For Debugger" forever

tuxdost
  • 133
  • 1
  • 14
  • Actually, the debug method is not constrained to work profile. The main idea is to attach the debugger to the process via Android Studio manually when you start the debugger on command line. – tuxdost Jan 23 '20 at 13:10
  • 2
    Tried this, but fails on step b with "Shell does not have permission to access user ##". Debugging is on. I can deploy and debug my app from the debugger, but since the work profile vpn is split tunnel, I need the app to run under the work profile to access internal corporate resources. – Paul Reedy May 14 '20 at 19:26
  • I'll check that again. I think this happens when you provide the wrong user id – tuxdost Jul 21 '21 at 11:13