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

前端 未结 30 1640
[愿得一人]
[愿得一人] 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:02

    To complete the answer of @usethe4ce, if you have more than one device or emulators, the adb tcpip 5555 will give error: more than one device/emulator.

    In this case you need to give the serial number of the desired device:

    1. adb devices

      List of devices attached

      33001229 device

      emulator-5554 device

    2. adb -s 33001229 tcpip 5555
    3. Find your device's IP in my case I can find it from the device's wifi connected settings.
    4. adb connect xxx.xxx.xxx.xxx:5555
    0 讨论(0)
  • 2020-11-22 08:02
    1. In Device Settigs-> "Developer options" -> "Revoke USB debugging authorizations".
    2. Connect the device via USB and make sure debugging is working.
    3. adb tcpip 5555
    4. adb connect <DEVICE_IP_ADDRESS>:5555
    5. Disconnect USB
    6. adb devices
    0 讨论(0)
  • 2020-11-22 08:02

    1- For this I am considering you have already installed the latest version of Android studio. If not you can download it from here.

    2 - You can set the platform tools path in environment variable (optional).

    3 - Make sure your device and pc connected to same network.

    • plug in the data cable from pc to device.

    • Now, type adb tcpip 5555

    • remove data cable.

    • Then type adb connect 192.168.43.95

    • here 5555 is the port number and 192.168.43.95 is the ip address of the mobile device you can get id address from the mobile settings .

    • Then go to About device and go to status you can see the ip address of the device.

    • You can connect multiple device from different ports which can give ease in development.

    • Or you can go to this link for brief description with screenshots. http://blogssolutions.co.in/connect-your-android-phone-wirelessly-by-adb

    0 讨论(0)
  • 2020-11-22 08:03

    I wrote a simple script for Windows:

    Step 1. Make a batch file with the below commands and call the file wifi_dedug.bat and copy the below contents:

        adb tcpip 5555
        pause
        adb shell "ip addr show wlan0  | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1" > tmpFile 
        pause
        set /p ip= < tmpFile 
        @echo %ip%
        del tmpFile
        @echo %ip%
        adb connect %ip%
        pause
    

    Step 2. connect your device to pc.

    Step 3. start batch file (key enter when requested)

    Step 4. disconnect your device and deploy/debug via wifi.

    0 讨论(0)
  • 2020-11-22 08:05

    If you want to enable wireless adb on the device without connecting with a USB cable at all (root required):

    1. Install a terminal app on the device (like Android Terminal Emulator) Type the following
    2. su
    3. setprop service.adb.tcp.port 5555
    4. stop adbd
    5. start adbd

    Since you already have the terminal opened, you can find the IP address of the device:

    ip addr show
    

    Then in your debugging environment run command:

    adb connect ip.of.the.device
    

    This will make the device to be listed as any other emulators you might have. Note that the TCP will stay opened until you reset the device. You might also want to install a Wi-Fi Keep Alive app if you often experience disconnects.

    Remember to close the TCP when connecting to public networks if you want to feel safe. You can do the following or simply restart the device:

    1. su
    2. setprop service.adb.tcp.port -1
    3. stop adbd
    4. start adbd
    0 讨论(0)
  • 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"
    
    0 讨论(0)
提交回复
热议问题