Wireless Android Debugging with Delphi xE5

Previously I blogged about how to connect to an emulator on a remote (or the host) machine. That also works for hardware connected to remote machines. But sometimes you want to work with hardware that isn’t even connected at all. Not to worry, here is how to wirelessly connect and debug with your favorite development tool. One note though, WiFi slower than a USB connection, so you will see a little delay sometimes.

Requirements:

  • A machine (Mac or PC) you can connect the Android device to that has ADB (Android Debug Bridge) installed. This is part of the Android SDK. As well as necessary ADB USB Drivers (required on Windows). This can be your development machine, or another machine.
  • A non-segmented wireless network that both your development machine and Android device are connected. (Segmenting prevents two connected devices from connecting to each other).

These commands work with ADB (Android Debug Bridge). It is easiest if you add it to your path. By default it is found in the following location, but you can install it anywhere on your system (Select the “Use An Existing IDE” option when downloading).

C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk\platform-tools

First you need to connect your Android device to any computer. With USB debugging turned on, verify you have access to the device via ADB with the following command:

Command:

adb devices

Output:

List of devices attached 
8605fa72        device

If the list is empty, then you need to enable USB debugging and make sure you have the USB ADB Bridge driver for your device installed.

Once ADB is setup, you can get the IP address with the following command:

adb shell netcfg|grep wlan0

Which should give you output like:

wlan0  UP     10.20.5.88/24  0x00001043 2a:32:11:42:aa:3c

Then put the device in TCPIP mode with the command:

adb kill-server
adb tcpip 5555

Then on your machine that is running Delphi XE5 go to the command window and type (with the IP address from above):

adb connect 10.20.5.88

Then you can verify it worked from that same command prompt

Command:

adb devices

Output:

List of devices attached
10.20.5.88:5555   device

And now you can connect to that device wirelessly from Delphi. Like I mentioned before, this is slower, so expect some delays on deploy and responding to breakpoints.

There is some more information on Stack Overflow, including some different options if you have a rooted Android device.

This entry was posted in Android and tagged . Bookmark the permalink.

6 Responses to Wireless Android Debugging with Delphi xE5

  1. iwancs says:

    I’ve tried it, i’ve connect my android device to my win 7 and on the adb tcpip 5555 step, it just don’t do anything, it doesn’t return to command prompt, it is like waiting to connect to the device but failed, so i tried to run the command prompt box in elevated mode (run as administrator) then i retry the step, but this time i run the adb kill-server and adb start-server first, then the adb tcpip 5555 will run immediately.
    Thanks

  2. Jim McKeeth says:

    Thanks, I’ll add “adb Kill-Server” as a step first.

  3. Look says:

    Hi, the device with Android must be rooted when I run my app directly from Delphi? I have LG e405 and I see it in ADB properly an I see it as Android Target in Delphi but when I run my app I get the message “unable to install project1.apk install_failed_insufficient_storage”. Why I get this message?

    Thank’s for any reply.

  4. Jim McKeeth says:

    Most of this doesn’t require root. The insufficient storage message means you don’t have enough storage (free some storage space – usually music, etc.)

  5. Pingback: Wirelessly Debug On Your Android Device With Delphi XE5 Firemonkey | Delphi XE5 Firemonkey, Delphi Android, Delphi IOS

  6. fraz says:

    The insufficient storage message in this instance does not necessarily mean there is a lack of storage. I have helped at least 2 people with this issue and it is not really storage space related. It was the “firewall” dialog that that pops up on device first time you connect with ADB**. Essentially that dialog is asking you to allow permission for your PC to connect. The users tried to deploy, didn’t have permission, and it was a false message letting them know they didn’t have permission to write to the storage. Had them allow connection permissions and everything deployed and worked great!

    **Sometimes this can be a pain to make appear. Turning on/off USB debugging, disconnecting/reconnecting device, sometimes a reboot is required to get this to show up intentionally.

Leave a Reply