我正在尝试通过adb
运行到Linux上新安装的android模拟器的反向tcp链接(试图调试来自react_native
构建的失败调用。):
adb -s emulator-5556 reverse --no-rebind tcp:0 tcp:8081
使用adb版本:
Android Debug Bridge version 1.0.41
Version 28.0.3-5475833
奇怪的是,与前向链接相同的命令可以正常工作。
我得到结果:
adb: error: cannot bind listener: Operation not permitted
现在看来,引发错误的是仿真器(通过strace和ADB_TRACE = all运行它之后,adb似乎只是从与之通信的进程的读取中收到此错误消息)。
使用以下命令发出对adbd进程的写入后,似乎失败了:
write(3, "0027reverse:forward:norebind:tcp:0;tcp:8081", 43) = 43
现在,这显然是一个发送到仿真器的命令协议。 (我无法通过在adb源周围轻弹来找到命令号27。是否有任何指针?)
为试图弄清楚到底出了什么问题,我尝试通过strace运行模拟器。 (它是否试图写入导致权限错误的文件?是在尝试打开套接字时引起的吗?)
这是ADBTRACE=all
日志(ADB_TRACE=all adb reverse --no-rebind tcp:0 tcp:8081
):
adb D 05-29 00:16:29 16167 16167 adb_trace.cpp:192] Android Debug Bridge version 1.0.41
adb D 05-29 00:16:29 16167 16167 adb_trace.cpp:192] Version 28.0.3-5475833
adb D 05-29 00:16:29 16167 16167 adb_trace.cpp:192] Installed as /home/something/Android/Sdk/platform-tools/adb
adb D 05-29 00:16:29 16167 16167 adb_trace.cpp:192]
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:327] adb_connect: service: reverse:forward:norebind:tcp:0;tcp:8081
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:153] _adb_connect: host:version
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:107] writex: fd=3 len=16 30303063686f73743a76657273696f6e 000chost:version
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4f4b4159 OKAY
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:187] _adb_connect: return fd 3
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 30303034 0004
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 30303239 0029
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:153] _adb_connect: reverse:forward:norebind:tcp:0;tcp:8081
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:107] writex: fd=3 len=18 30303065686f73743a74706f72743a61 000ehost:tport:a [truncated]
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:113] Switch transport in progress: host:tport:any
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4f4b4159 OKAY
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=8
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=8 got=8 0d00000000000000 ........
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:127] Switch transport success
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:107] writex: fd=3 len=43 30303237726576657273653a666f7277 0027reverse:forw [truncated]
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4f4b4159 OKAY
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:187] _adb_connect: return fd 3
adb D 05-29 00:16:29 16167 16167 adb_client.cpp:345] adb_connect: return fd 3
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4641494c FAIL
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 30303264 002d
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:81] readx: fd=3 wanted=45
adb D 05-29 00:16:29 16167 16167 adb_io.cpp:97] readx: fd=3 wanted=45 got=45 63616e6e6f742062696e64206c697374 cannot bind list [truncated]
adb: error: cannot bind listener: Operation not permitted
使用以下命令运行模拟器时:
strace -s 10000 -f emulator -avd Pixel_2_API_Q 2>&1 | grep -C100 reverse
我得到:
[pid 26748] recvfrom(79, "reverse:forward:norebind:tcp:0;tcp:8081\0", 40, 0, NULL, NULL) = 40
[pid 26748] ioctl(54, KVM_RUN, 0) = 0
[pid 26748] recvfrom(79, 0x7f7b49edec50, 24, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
[pid 26748] ioctl(54, KVM_RUN, 0) = 0
[pid 26748] write(31, "\1\0\0\0\0\0\0\0", 8) = 8
[pid 26729] <... ppoll resumed>) = 1 ([{fd=31, revents=POLLIN}], left {tv_sec=0, tv_nsec=9712500})
[pid 26748] write(28, "\1\0\0\0\0\0\0\0", 8 <unfinished ...>
[pid 26729] futex(0x2f80ce8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid 26748] <... write resumed>) = 8
[pid 26748] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1) = 1
[pid 26729] <... futex resumed>) = 0
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26729] read(31, "\1\0\0\0\0\0\0\0", 16) = 8
[pid 26729] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26729] ppoll([{fd=31, events=POLLIN}, {fd=30, events=POLLIN}, {fd=26, events=POLLIN}, {fd=28, events=POLLIN}, {fd=52, events=POLLIN}, {fd=64, events=POLLIN}, {fd=65, events=POLLIN}, {fd=66, events=POLLIN}, {fd=67, events=POLLIN}, {fd=69, events=POLLIN}, {fd=71, events=POLLIN}, {fd=73, events=POLLIN}, {fd=75, events=POLLIN}, {fd=77, events=POLLIN}, {fd=50, events=POLLIN}, {fd=51, events=POLLIN}, {fd=34, events=POLLIN}, {fd=79, events=POLLIN}], 18, {tv_sec=0, tv_nsec=9404000}, NULL, 8 <unfinished ...>
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26729] <... ppoll resumed>) = 1 ([{fd=28, revents=POLLIN}], left {tv_sec=0, tv_nsec=9399241})
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26729] read(31, <unfinished ...>
[pid 26748] futex(0x2f80ce8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid 26729] <... read resumed>0x7f7bb75925a0, 16) = -1 EAGAIN (Resource temporarily unavailable)
[pid 26729] read(28, "\1\0\0\0\0\0\0\0", 512) = 8
[pid 26729] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 26748] <... futex resumed>) = 0
[pid 26729] <... futex resumed>) = 1
[pid 26729] ppoll([{fd=31, events=POLLIN}, {fd=30, events=POLLIN}, {fd=26, events=POLLIN}, {fd=28, events=POLLIN}, {fd=52, events=POLLIN}, {fd=64, events=POLLIN}, {fd=65, events=POLLIN}, {fd=66, events=POLLIN}, {fd=67, events=POLLIN}, {fd=69, events=POLLIN}, {fd=71, events=POLLIN}, {fd=73, events=POLLIN}, {fd=75, events=POLLIN}, {fd=77, events=POLLIN}, {fd=50, events=POLLIN}, {fd=51, events=POLLIN}, {fd=34, events=POLLIN}, {fd=79, events=POLLIN}], 18, {tv_sec=0, tv_nsec=9246000}, NULL, 8 <unfinished ...>
[pid 26748] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 26748] ioctl(54, KVM_RUN, 0) = 0
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26747] <... ioctl resumed>, 0) = 0
[pid 26747] ioctl(53, KVM_RUN <unfinished ...>
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26748] ioctl(54, KVM_RUN, 0) = 0
[pid 26747] <... ioctl resumed>, 0) = 0
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26747] sendto(79, "OKAY\256\2\0\0X\1\0\0\0\0\0\0\0\0\0\0\260\264\276\246", 24, MSG_NOSIGNAL, NULL, 0 <unfinished ...>
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26747] <... sendto resumed>) = 24
[pid 26747] ioctl(53, KVM_RUN <unfinished ...>
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26747] <... ioctl resumed>, 0) = 0
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26747] sendto(79, "WRTE\256\2\0\0X\1\0\0005\0\0\0\0\0\0\0\250\255\253\272", 24, MSG_NOSIGNAL, NULL, 0 <unfinished ...>
[pid 26748] futex(0x2f80ce8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid 26747] <... sendto resumed>) = 24
[pid 26747] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 26748] <... futex resumed>) = 0
[pid 26747] <... futex resumed>) = 1
[pid 26748] futex(0x2f80ce8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 26747] ioctl(53, KVM_RUN <unfinished ...>
[pid 26748] <... futex resumed>) = 0
[pid 26748] ioctl(54, KVM_RUN <unfinished ...>
[pid 26747] <... ioctl resumed>, 0) = 0
[pid 26748] <... ioctl resumed>, 0) = 0
[pid 26747] sendto(79, "FAIL002dcannot bind listener: Operation not permitted", 53, MSG_NOSIGNAL, NULL, 0 <unfinished ...>
现在,除非在kvm_run内出现错误(我不是对kvm熟悉的 super ),否则这没有多大意义。
所以我假设这是一个简单的权限问题,但是我的混乱使我无法弄清权限问题在哪里。
有人能帮助阐明如何处理adb的此错误吗?有没有strace / kvm向导可以指出我如何找出此权限错误在哪里?
答案 0 :(得分:0)
尝试以root权限重新启动adbd守护程序:
adb kill-server; adb root