【问题标题】:How to run logcat on multiple devices?如何在多个设备上运行 logcat?
【发布时间】:2011-06-01 14:57:45
【问题描述】:

如何同时在多个设备上运行 logcat? “adb logcat”命令报错:

error: more than one device and emulator

【问题讨论】:

    标签: android device adb logcat


    【解决方案1】:

    使用adb-s 选项:

    adb -s <serialnumber>
    

    示例

    C:\Users\lel>adb devices
    List of devices attached
    192.168.198.101:5555    device
    0123456789ABCDEF        device
    
    adb -s 0123456789ABCDEF logcat
    adb -s 192.168.198.101:5555 logcat
    

    您可以将grep 与此结合起来,以获取包含它的所有行。
    一个例子是System.out

    例子:

     adb -s 192.168.198.101:5555 logcat | grep "System.out"
    

    【讨论】:

    • 我想我下次会更加注意adb参数...抱歉提出这么明显的问题。 :)
    • 你是怎么得到序列号的?我尝试使用 adb 设备,但这给了我这个附加的设备列表 HT05XPL09783 设备 100082a42935 设备和 adb logcat -s 100082a42935 不起作用
    • 我发现我的愚蠢错误应该保持像 adb -s 100082a42935 logcat
    【解决方案2】:

    我认为它可能有用。我有这个对我有很大帮助的脚本。它将每个设备记录到不同的文件中。要停止记录,只需按 CTRL+C。

    #! /bin/bash
    
    devices=`adb devices | grep 'device$' | cut -f1`
    pids=""
    
    for device in $devices
    do
        log_file="$device-`date +%d-%m-%H:%M:%S`.log"
        echo "Logging device $device to \"$log_file\""
        adb -s $device logcat -v threadtime > $log_file &
        pids="$pids $!"
    done
    
    echo "Children PIDs: $pids"
    
    killemall()
    {
        echo "Killing children (what a shame...)"
    
        for pid in $pids
        do
            echo "Killing $pid"
            kill -TERM $pid
        done
    }
    
    trap killemall INT
    
    wait
    

    【讨论】:

      【解决方案3】:

      使用您的设备 ip:
      adb -s device_ip:5555

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-06
        • 1970-01-01
        • 2015-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-05
        • 1970-01-01
        相关资源
        最近更新 更多