ADB root 无法在模拟器上运行(无法在生产版本中以 root 身份运行) [英] ADB root is not working on emulator (cannot run as root in production builds)

查看:210
本文介绍了ADB root 无法在模拟器上运行(无法在生产版本中以 root 身份运行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新了模拟器 26.0.3,现在我无法为新创建的模拟器运行 adb root 命令.

I have just updated emulator 26.0.3, now I cannot run adb root command for new created emulator.

显示的错误如下:

adbd 无法在生产版本中以 root 身份运行

我已经杀死并重新启动 adbd 比如:

I have killed and restart adbd like:

adb kill-server
adb devices

没有任何帮助,有什么想法吗?

Nothing helps, any ideas?

我不确定有什么区别以及如何选择不同的构建,但是,如果在创建时启用了以下设置,则它具有 root.

I am not sure what is the difference and how to select different build but, if following settings are enabled while creating, then it has root.

推荐答案

要启用 root 访问权限: 选择未标记为Google Play"的模拟器系统映像.(标签文本和其他 UI 细节因 Android Studio 版本而异.)

To enable root access: Pick an emulator system image that is NOT labelled "Google Play". (The label text and other UI details vary by Android Studio version.)

例外情况:截至 2020 年 10 月 8 日,Release R Android TV"系统映像不会以 root 身份运行.解决方法:改用 Release Q(API 级别 29)Android TV 系统映像.

Exception: As of 2020-10-08, the Release R "Android TV" system image will not run as root. Workaround: Use the Release Q (API level 29) Android TV system image instead.

测试它:启动模拟器,然后运行 ​​adb root.应该说

Test it: Launch the emulator, then run adb root. It should say

  • 以root身份重启adbd

  • adbd 已经以 root 身份运行

不是

  • adbd 无法在生产版本中以 root 身份运行

替代测试:运行adb shell,如果提示以$结尾,运行su.它应该显示 # 提示符.

Alternate test: Run adb shell, and if the prompt ends with $, run su. It should show a # prompt.

步骤:安装和使用可以以root身份运行的模拟器镜像:

Steps: To install and use an emulator image that can run as root:

  1. 在 Android Studio 中,使用菜单命令 Tools >AVD 管理器.
  2. 点击 + 创建虚拟设备... 按钮.
  3. 选择虚拟硬件,然后点击下一步.
  4. 选择一个系统映像.
    • 选择任何说(Google Play)"的图片在目标"列中.
    • 如果您依赖 Google API(Google Sign In、Google Fit 等),请选择标有(Google API)"的图片.
    • 您可能需要从推荐"切换到分组到x86 图像";或其他图像"组找到一个.
  1. In Android Studio, use the menu command Tools > AVD Manager.
  2. Click the + Create Virtual Device... button.
  3. Select the virtual Hardware, and click Next.
  4. Select a System Image.
    • Pick any image that does NOT say "(Google Play)" in the Target column.
    • If you depend on Google APIs (Google Sign In, Google Fit, etc.), pick an image marked with "(Google APIs)".
    • You might have to switch from the "Recommended" group to the "x86 Images" or "Other Images" group to find one.
  • 提示:以 API 级别编号开头的 AVD 名称,以便虚拟设备列表按 API 级别排序.

[信用属于@Merk,但这应该作为答案而不是评论发布.]

[Credit belongs to @Merk but this should be posted as an answer rather than a comment.]

这篇关于ADB root 无法在模拟器上运行(无法在生产版本中以 root 身份运行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆