【问题标题】:"adb root" command returns "adbd cannot run as root in production builds" even on an emulator?即使在模拟器上,“adb root”命令也会返回“adbd 不能在生产版本中以 root 身份运行”?
【发布时间】:2019-05-08 18:45:28
【问题描述】:

我正在尝试在模拟器上运行adb root 命令;这是我连接的唯一设备:

$ adb devices
List of devices attached
emulator-5554   device

但是,我收到以下错误消息:

$ adb root
adbd cannot run as root in production builds

我已经尝试按照这个答案adb shell su works but adb root does not 来解决我的问题:

按照设计,adb root 命令仅适用于开发版本(即默认情况下具有 ro.debuggable=1 的 eng 和 userdebug)。或者,您可以使用修改后的 adbd 二进制文件(不检查 ro.debuggable)

但是,我不清楚如何将构建更改为开发构建而不是生产构建?

更新 我发现了一些额外的说明,让我相信要让它工作,你需要让你的模拟器成为一个“可写系统”(参见How to make system partition in AVD in emulator writable)。但是,如果我尝试

$ emulator -avd Nexus_5X_API_28 -writable-system
emulator: WARNING: System image is writable
emulator: ERROR: Running multiple emulators with the same AVD is an experimental feature.
Please use -read-only flag to enable this feature.

我不确定如何解析此错误消息;这是否意味着系统镜像已经是可写的了?

【问题讨论】:

标签: android adb


【解决方案1】:

我检查了谷歌提供的一些模拟器。 它们都是用户二进制文件,而不是工程师二进制文件。 您可以使用“adb shell”命令自行检查。 如果命令行以“#”开头,则为工程师构建。如果它以“$”开头,它是用户构建。例如:

  • jackpot2lte:/ # => 工程师构建
  • jackpot2lte:/ $ => 用户构建

只有工程师构建才能授予您 root 权限。您不能将用户构建更改为工程师构建,但您可以“root”它。 更多信息请查看"How to get root access on Android emulator?"

【讨论】:

  • 确实,我在adb shell 中看到$,表明它是用户构建的。但是,从上面的评论看来,还有一个userdebug 构建?
【解决方案2】:

选择未标记为“Google Play”的模拟器系统映像。

来自https://stackoverflow.com/a/45668555

【讨论】:

    猜你喜欢
    • 2017-10-10
    • 2014-10-05
    • 1970-01-01
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多