(OK) adb 连接错误【error: device unauthorized】的解决 - 从源码层面解决

--------------------------------
adb kill-server
adb connect 192.168.56.6
--------------------------------
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
connected to 192.168.56.6:5555
--------------------------------
adb shell
--------------------------------
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
--------------------------------

--------------------------------
vim system/core/adb/daemon/main.cpp
-------------------------------- use

    if (ALLOW_ADBD_NO_AUTH && property_get_bool("ro.adb.secure", 0) == 0) {
        auth_required = false;
    }
                    // 添加下面这行,解决【error: device unauthorized】,正式发布 android 时,要还原
        auth_required = false;
--------------------------------

--------------------------------
grep "ro\.kernel\.qemu" -R . --exclude-dir=out --exclude-dir='\.git' --exclude-dir=external --exclude-dir=cts --exclude-dir=prebuilts
-------------------------------- look
vim device/generic/common/init.x86.rc
--------------------------------
on property:debug.egl.hw=0
    setprop ro.kernel.qemu 1
--------------------------------

--------------------------------
grep "debug\.egl\.hw" -R . --exclude-dir=out --exclude-dir='\.git' --exclude-dir=external --exclude-dir=cts --exclude-dir=prebuilts
--------------------------------
vim device/generic/common/init.sh
-------------------------------- use
        bootcomplete)
                do_bootcomplete
                    // add the below line,添加这行,即可自动启动adbd,正式发布 android 时,要还原
                set_property debug.egl.hw 0
--------------------------------

--------------------------------
// vim system/core/rootdir/init.usb.rc
vim system/core/rootdir/init.rc
-------------------------------- use
    start console
                    // add the below line, adbd will automatically start
# adbd is controlled via property triggers in init.<platform>.usb.rc
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
    class core
    socket adbd stream 660 system system
    disabled
    seclabel u:r:adbd:s0

# adbd on at boot in emulator
on property:ro.kernel.qemu=1
    start adbd
                    // 设置系统的ro.kernel.qemu属性为1,即将手机当成模拟器
--------------------------------------------------------------------

posted @   张同光  阅读(1329)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示