Run/install/debug Android applications over Wi-Fi?

前端 未结 30 2315
[愿得一人]
[愿得一人] 2020-11-22 07:16

I thought there was a way to test your applications in development over Wi-Fi. Is this possible?

I\'d love to be able to untether my phone and develop wirelessly.

30条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 08:06

    I wrote a shell script which can let you debug an Android device via Wi-Fi.

    Here is the code:

    #!/usr/bin/env bash
    #Notice: if unable to connect to [ip]:5555,
    #try adb kill-server then try again.
    
    adb shell ip route > addrs.txt
    #Case 1:Nexus 7
    #192.168.88.0/23 dev wlan0  proto kernel  scope link  src 192.168.89.48
    
    #Case 2: Smartsian T1,Huawei C8813
    #default via 192.168.88.1 dev eth0  metric 30
    #8.8.8.8 via 192.168.88.1 dev eth0  metric 30
    #114.114.114.114 via 192.168.88.1 dev eth0  metric 30
    #192.168.88.0/23 dev eth0  proto kernel  scope link  src 192.168.89.152  metric 30
    #192.168.88.1 dev eth0  scope link  metric 30
    
    ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
    
    echo "the device ip address is $ip_addrs"
    
    echo "connecting..."
    
    rm addrs.txt
    
    adb tcpip 5555
    
    adb connect "$ip_addrs"
    

提交回复
热议问题