通过Android中的ADB在工作资料中安装APK [英] Install APK in Work Profile via ADB in Android
问题描述
假设我们在Android设备中启用了工作资料(Android For Work).有谁知道如何通过Work个人资料而非个人资料通过ADB安装APK.
Let's say we have a Work Profile (Android For Work) enabled in Android device. Does anyone know how to install an APK via ADB in Work Profile rather than personal profile.
我看过ADB文档,有一种获取用户ID的方法,但是使用相同的ID我无法安装APK.
I have seen the ADB documentation and there's a way to get the User ID but using the same ID I am unable to install an APK.
要获取ID: adb shell pm列表用户
安装命令: adb install -r --user 12 app_name.apk
To get ID : adb shell pm list users
Install command : adb install -r --user 12 app_name.apk
错误消息:
Performing Streamed Install
adb: failed to install app-prodDebug.apk: Security exception: Shell does not have permission to access user 12
com.android.server.am.ActivityManagerService.handleIncomingUser:22541 android.app.ActivityManager.handleIncomingUser:3989 com.android.server.pm.PackageManagerShellCommand.translateUserId:2434
java.lang.SecurityException: Shell does not have permission to access user 12
com.android.server.am.ActivityManagerService.handleIncomingUser:22541 android.app.ActivityManager.handleIncomingUser:3989 com.android.server.pm.PackageManagerShellComma
有什么办法可以解决这个问题?我的用例是替换启用了调试选项的应用程序,以便我对在工作资料中安装的特定应用程序发生的任何问题进行故障排除.
Any way to get around this ? My use case here is to replace an App with debug option enabled so that I can troubleshoot any issue that is happening with that specific app which is installed in work profile.
推荐答案
adb push android.apk /data/local/tmp
adb shell pm install --user 12 /data/local/tmp/android.apk
这篇关于通过Android中的ADB在工作资料中安装APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!