美文网首页
adb 命令

adb 命令

作者: 乘风破浪的程序员 | 来源:发表于2020-05-25 15:35 被阅读0次

    1:

    获取当前设备 CPU 类型:

    adb shell getprop ro.product.cpu.abi
    

    输出:

    arm64-v8a
    

    2:

    adb 连接不上手机,报错:

     adb devices
    * daemon not running; starting now at tcp:5037
    ADB server didn't ACK
    Full server startup log: /var/folders/yq/jrwmxg1137lg1w9tmrl1v23w0000gn/T//adb.501.log
    Server had pid: 5327
    --- adb starting (pid 5327) ---
    adb I 06-09 15:40:35  5327 102249 main.cpp:60] Android Debug Bridge version 1.0.41
    adb I 06-09 15:40:35  5327 102249 main.cpp:60] Version 29.0.5-5949299
    adb I 06-09 15:40:35  5327 102249 main.cpp:60] Installed as /Users/woshihante/Library/Android/sdk/platform-tools/adb
    adb I 06-09 15:40:35  5327 102249 main.cpp:60] 
    adb E 06-09 15:40:35  5327 102252 usb_osx.cpp:159] Unable to create an interface plug-in (e00002be)
    adb I 06-09 15:40:35  5327 102252 usb_osx.cpp:308] reported max packet size for 6c1ca1f7 is 512
    adb F 06-09 15:40:36  5327 102249 main.cpp:144] could not install *smartsocket* listener: Address already in use
    adb E 06-09 15:40:36   916 11995 usb_osx.cpp:159] Unable to create an interface plug-in (e00002be)
    
    * failed to start daemon
    adb: failed to check server version: cannot connect to daemon
    
    

    解决办法,查看占用进程:

    sudo lsof -i :5037
    
     COMMAND    PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    studio    5035 woshi    69u  IPv4 0x28e97a999251351b      0t0  TCP localhost:61641->localhost:5037 (ESTABLISHED)
    studio    5035 woshi    71u  IPv4 0x28e97a99925148db      0t0  TCP localhost:61642->localhost:5037 (ESTABLISHED)
    Google    5924 woshi    20u  IPv4 0x28e97a99ae19d51b      0t0  TCP localhost:61537->localhost:5037 (ESTABLISHED)
    adb       5948 woshi     6u  IPv4 0x28e97a99925152bb      0t0  TCP localhost:5037->localhost:61641 (ESTABLISHED)
    adb       5948 woshi     8u  IPv4 0x28e97a999e8c2efb      0t0  TCP localhost:5037->localhost:61642 (ESTABLISHED)
    adb       5948 woshi    10u  IPv4 0x28e97a999b7808db      0t0  TCP localhost:5037 (LISTEN)
    adb       5948 woshi    11u  IPv4 0x28e97a99a1306c9b      0t0  TCP localhost:5037->localhost:61537 (ESTABLISHED)
    

    然后根据PID杀进程:

    sudo kill -9 5948

    此处可能会有多个,多执行几次 sudo kill 即可

    3

    获取当前设备打开的页面路径

    adb shell "dumpsys window | grep mCurrentFocus"
    
     ~ adb shell "dumpsys window | grep mCurrentFocus"
      mCurrentFocus=Window{44614ab u0 com.instagram.android/com.instagram.mainactivity.MainActivity}
    
     ~ adb shell "dumpsys window | grep mCurrentFocus"
      mCurrentFocus=Window{ecd21d3 u0 com.android.vending/com.android.vending.AssetBrowserActivity}
    

    4

    adb 查看当前apk 的 MD5、sha1

    ➜  ~ keytool -printcert -jarfile xxxxx.apk
    

    5

    adb 查看签名文件 .jks 的 MD5、SHA1

    keytool -list -v -keystore  <.jsk path>  -storepass <Password>
    

    相关文章

      网友评论

          本文标题:adb 命令

          本文链接:https://www.haomeiwen.com/subject/acvyahtx.html