Source Code Easy way: How to Deploy your app to Android device using WiFi network (no USB cable) - thanks to MalcomM

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
here a great tip by StackOverFlow very usual for many situation, mainly when your MSWindows stay "fighting" with your USB cable from Android device! My case!
[SHOWTOGROUPS=4,20,22]
  1. You need be in the same network, PC and Android device, of course!
  2. Active your "Developer Options" in your Android! Для просмотра ссылки Войди или Зарегистрируйся
  3. Connect the device via USB and make sure debugging is working;
  4. adb tcpip 5555. This makes the device to start listening for connections on port 5555; - you can use another avaliable!
  5. Look up the device IP address with adb shell netcfg or adb shell ifconfig with 6.0 and higher;
  6. You can disconnect the USB now;
  7. adb connect <DEVICE_IP_ADDRESS>:5555. This connects to the server we set up on the device on step 2;
  8. Now you have a device over the network with which you can debug as usual.
To switch the server back to the USB mode, run adb usb, which will put the server on your phone back to the USB mode.
If you have more than one device, you can specify the device with the -s option: adb -s <DEVICE_IP_ADDRESS>:5555 usb.

No root required!

To find the IP address of the device: run adb shell and then netcfg. You'll see it there. To exit of shell, type exit.

To find the IP address while using OSX /MSWindows (too) run the command adb shell ip route. <--- works better!

WARNING: leaving the option enabled is dangerous, anyone in your network can connect to your device in debug, even if you are in data network. Do it only when connected to a trusted Wi-Fi and remember to disconnect it when done!

Sergei suggested that line 2 should be modified, commenting: "-d option needed to connect to the USB device when the other connection persists (for example, emulator connected or other Wi-Fi device)".

This information may prove valuable to future readers, but I rolled-back to the original version that had received 178 upvotes.

On some device you can do the same thing even if you do not have an USB cable:

  1. Enable ADB over network in developer setting
  2. 8euGG.png
  3. It should show the IP address (if not, no problem - your edition can dont show this info)
  4. adb connect <DEVICE_IP_ADDRESS>:5555
  5. Disable the setting when done
thanks to Для просмотра ссылки Войди или Зарегистрируйся

more info Для просмотра ссылки Войди или Зарегистрируйся

If you dont understand, here a summary:
  1. Connect your USB cable between PC and Android smartphone
  2. type the command: adb tcpip <<port_number>> ---> if the port is not accessible, the ADB try another and show to you!
  3. Disconnect your USB cable, it's not usable now!
  4. type the command: adb connect <<ip_address_of_your_device_in_your_wifi_network>>:<<port_number_showed_by_adb_above>>
  5. It's ready! Now you can deploy your app using your RAD Studio IDE like before when using USB cable!
  6. If you want come back use USB cable type command: adb usb
  7. Dont forget, read above the warning about using this way access your device using a open-network!
  8. On your device, deselect the "Developer Options" to avoid using advanced options like this.
the ADB.exe is in your Platfom SDK Windows folder, in "..\platform-tools\adb.exe"

You can also set an environment variable called ADBHOST with the IP address and adb will attempt to connect to that ip.

Now I am not sure if DDMS can connect to the device over tcpip, but if adb can, and ddms uses adb to connect, it should be possible.
[/SHOWTOGROUPS]
 
Последнее редактирование: