【问题标题】:How to debug Apps in Android Enterprise Work Profile如何在 Android Enterprise Work Profile 中调试应用程序
【发布时间】:2020-04-27 09:07:35
【问题描述】:

我刚开始使用 Android Enterprise 进行开发,需要在工作资料中部署一个应用。

我的政策(见下文)允许安装带有调试版本变体的 apk。通过 Android Studio 启动调试会话现在将应用程序安装在私有和工作配置文件中,这意味着该策略在工作配置文件上处于活动状态。 但是,调试会话始终连接到私有配置文件中的应用程序。

是否可以直接在工作配置文件上启动到应用实例的调试会话?

我还尝试过使用用户标志:

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

但是,连接超时。

这是我的政策:

{
  "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
}

【问题讨论】:

    标签: android debugging adb remote-debugging


    【解决方案1】:

    这对我来说是这样的。

    将带有工作配置文件的手机连接到 PC,并确保 USB 调试可用。

    构建一个新的 debug.apk

    以下命令必须在 Android Studio 的终端中输入。

    a) 检查用户 tux@C:>adb shell pm list users

    用户:

    UserInfo{0:owner:13} 正在运行 UserInfo{12:Work profile:30} 正在运行

    b) 安装应用程序 tux@C:>adb install --user 12 "c:\dev\source\test\ShareXml\app\build\outputs\apk\debug\app-debug.apk"

    c) 启动调试器 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) 手动将进程连接到 Android Studio 中的调试器(参见随附的屏幕截图)

    这篇文章帮我解决了这个问题:Debugging with Android Studio stuck at "Waiting For Debugger" forever

    【讨论】:

    • 实际上,debug 方法不受工作配置文件的限制。主要思想是在命令行启动调试器时,通过 Android Studio 手动将调试器附加到进程。
    • 试过了,但在步骤 b 中失败,并显示“Shell 没有访问用户 ## 的权限”。调试已开启。我可以从调试器部署和调试我的应用程序,但由于工作配置文件 vpn 是拆分隧道,我需要应用程序在工作配置文件下运行才能访问内部公司资源。
    • 我会再检查一遍。我认为当您提供错误的用户 ID 时会发生这种情况
    猜你喜欢
    • 2015-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多