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

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

    Though there are so many good answers, here is my two cents for the future me :P and for anyone who wants it quick and easy.

    For Mac:

    • connect the device using USB first and make sure debugging is working. Disconnect any other devices and quit emulators.
    • open terminal and run the following script

      adb tcpip 5555
      adb connect $(adb shell ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | cut -d: -f2):5555
      
    • disconnect USB connection and the device should be available for WiFi debugging

    Explanation:

    adb tcpip 5555 commands the device to start listening for connections on port 5555

    adb connect $(_ip_address_fetched_):5555 tells to connect on port 5555 of the _ip_address_fetched_ address

    where _ip_address_fetched_ includes following:

    adb shell ifconfig getting internet configurations using adb shell

    grep "inter " filter any line that starts with inter

    grep -v 127.0.0.1 exclude localhost.

    At this point, output should be like:

    inet addr:###.###.#.### Bcast:###.###.#.### Mask:255.255.255.0

    awk '{print $2}' get the second part of the components array, separated by space (I'm using zsh).

    The output up to this point is

    addr:###.###.#.###

    cut -d: -f2 split the string by delimiter : and take second part. It will only take your device IP address

    0 讨论(0)
  • 2020-11-22 07:49

    For Ubuntu / Linux:

    1. Make sure your device is working for debugging: http://developer.android.com/tools/help/adb.html#Enabling
    2. Go to your sdk folder and find the folder platform-tools
    3. Use ./adb devices to list the connected devices. Make sure it is only one device connected and no emulator running.
    4. Find your device IP address, you can find it in your device: http://developer.android.com/tools/help/adb.html#wireless, or got adb shell like this: ./adb shell then netcfg. You will see a list of IP addresses. Find wlan0, in my case 192.168.100.3/2.
    5. ./adb tcpip 5555
    6. Finally enter ./adb connect <Your device IP Address>:5555 in your terminal. You can now deploy the application to your device over Wi-Fi.
    0 讨论(0)
  • 2020-11-22 07:51

    I found my answer here:

    1. Connect Android device and adb host computer to a common Wi-Fi network accessible to both. We have found that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support adb.
    2. Connect the device with USB cable to host.
    3. Make sure adb is running in USB mode on host.

      $ adb usb
      restarting in USB mode
      
    4. Connect to the device over USB.

       $ adb devices
       List of devices attached
       ######## device
      
    5. Restart host adb in tcpip mode.

      $ adb tcpip 5555
      restarting in TCP mode port: 5555
      
    6. Find out the IP address of the Android device: Settings -> About tablet -> Status -> IP address. Remember the IP address, of the form #.#.#.#. sometimes its not possible to find the IP-address of the android device, as in my case. so u can get it using adb as the following: $ adb shell netcfg and the should be in the last line of the result.

    7. Connect adb host to device:

      $ adb connect #.#.#.#
      connected to #.#.#.#:5555
      
    8. Remove USB cable from device, and confirm you can still access device:

      $ adb devices
      List of devices attached
      #.#.#.#:5555 device
      

    You're now good to go!

    If the adb connection is ever lost:

    1. Make sure that your host is still connected to the same Wi-Fi network your Android device is.
    2. Reconnect by executing the "adb connect" step again.
    3. Or if that doesn't work, reset your adb host:

       adb kill-server
      

    and then start over from the beginning.

    0 讨论(0)
  • 2020-11-22 07:51

    The best way is using ADBConnect (Eclipse plugin) and ADB Wireless (app for Android device).

    0 讨论(0)
  • 2020-11-22 07:53

    After a long search I found :

    I must run

    adb connect <device_ip_address>:5555 
    

    after disconnecting USB.

    0 讨论(0)
  • 2020-11-22 07:53

    Download the app Wifi ADB on the play store. Very easy to use and works like a charm! :)

    0 讨论(0)
提交回复
热议问题