解决 ‘adb root‘ 时提示 ‘adbd cannot run as root in production builds‘

测试手机是红米3s,刷了原生第三方rom,安卓9.0

在刷了magisk获取root权限后,adb调试无法获取root权限。

注意:

1.在手机上,装上安卓终端软件,直接在本地系统上root是可以的

2.远程调试,不管是有线adb还是wifi adb,都无法通过adb root提权,但是可以在进入shell后再通过su切换到root

谷歌了下,发现是安卓9的限制以及magisk的问题,

https://github.com/topjohnwu/Magisk/issues/425

解决方法1:

关闭magisk的hide模式,然后重启手机,解决。但也失去了hide功能

或者可以修改magisk的配置文件ro.debuggable为1,因为安卓9默认在正式版是不支持adb root的,需要手动打开

解决方法2:

adb shell su works but adb root does not

By design adb root command works in development builds only (i.e. eng and userdebug which have ro.debuggable=1 by default). So to enable the adb root command on your otherwise rooteddevice just add the ro.debuggable=1 line to one of the following files:

/system/build.prop
/system/default.prop
/data/local.prop

If you want adb shell to start as root by default - then add ro.secure=0 as well.

原理跟上面的一样,改debuggabel为许可。但这个方法我尝试了没效果

解放方法3:

重新编译adbd,修改为可以调试,比较高级,我就不尝试了。

Alternatively you could use modified adbd binary (which does not check for ro.debuggable)

From https://android.googlesource.com/platform/system/core/+/master/adb/daemon/main.cpp

#if defined(ALLOW_ADBD_ROOT)
// The properties that affect `adb root` and `adb unroot` are ro.secure and
// ro.debuggable. In this context the names don't make the expected behavior
// particularly obvious.
//
// ro.debuggable:
//   Allowed to become root, but not necessarily the default. Set to 1 on
//   eng and userdebug builds.
//
// ro.secure:
//   Drop privileges by default. Set to 1 on userdebug and user builds.

解决方法4:

Launch a script as root through ADB

最简单不用修改任何文件的方法,直接在进入adb shell后,开启su

但对于某些特殊需求,比如需要在PC上写一个脚本,一开始获取root权限,然后逐条执行adb命令,就麻烦了

可以修改执行命令的方式,例如: adb shell "su  xxx",这样就可以通过root权限执行xxx命令了

#执行多条命令
adb shell "su -c '命令1; 命令2'"

#分行执行多条命令
adb shell "su -c '
    命令1;
    命令2
'"

#例子
adb shell "su -c '
    cd data;
    cd data;
    ls
'"

原文来自:解决 'adb root' 时提示 'adbd cannot run as root in production builds' - Jeason1997 - 博客园测试手机是红米3s,刷了原生第三方rom,安卓9.0 在刷了magisk获取root权限后,adb调试无法获取root权限。 注意: 1.在手机上,装上安卓终端软件,直接在本地系统上root是可以的 https://www.cnblogs.com/jeason1997/p/12410537.html

  • 6
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值