Run Or Debug Android App Using Wifi on Real Device

In this post, we will learn how to run or debug android app using wifi on real device. We will see how to run android app without using USB. Running app using usb cable for longer duration may damage usb port of device. So, developer like us sometimes look for alternate option. Alternate option is using default emulator in android studio or Genymotion emulator. There is another option – Using real device wirelessly (i.e. without using USB cable).

Why do we need wireless connection for debugging?

There are some limitations in wired debugging.

  • You always need a USB cable to run your application.
  • Attaching devices with a USB cable limits movement of the device.
  • Device should be properly connected while debugging android application
  • Port connection may become loose overtime.

In wireless debugging –

  • There is no need of USB cable.
  • Since, device is not physically connected, there is no limitation of device movements while debugging android application.
  • There is no point of loose connection since Android device is not physically connected with the laptop.

Getting Started

We have already seen several ways to run or debug android app in –

Now, we will see how to run or debug wirelessly on real device i.e. without using USB.

We are using Mi 10i phone for this tutorial. So, steps will be provided accordingly. However, most of the steps will be similar for other device.

Check Connected Devices

Here, we will see how to check for android devices connected with system. If it’s first time, we need to do below setup. Otherwise, we can move to next section of this tutorial.

Follow steps below –

  • In laptop, open terminal and type adb devices.
    adb devices
    

    If it’s showing list of connected devices. Then, it’s ok. But, it may show error “Command not found”. It means you are running it for first time. So, you need to set path for sdk/tools and sdk/platform-tools location.

  • Go to home (~) in terminal. Then, create a .bash_profile. Run below command to create that file.
    touch .bash_profile
    

    It will create .bash_profile file.

  • Open .bash_profile file. Run below command to open it.
    open -e .bash_profile
    
  • Then, write below two lines in .bash_profile file.
    export PATH=${PATH}:PATH_WHERE_SDK_IS_LOCATED/sdk/tools
    export PATH=${PATH}:PATH_WHERE_SDK_IS_LOCATED/sdk/platform-tools
    

    PATH_WHERE_SDK_IS_LOCATED is path where you sdk folder is present in laptop.In my case, sdk is located at /Users/rajeevkumar/Library/Android/sdk. So, above two lines will be like –

    export PATH=${PATH}:/Users/rajeevkumar/Library/Android/sdk/tools
    export PATH=${PATH}:/Users/rajeevkumar/Library/Android/sdk/platform-tools
    
  • Take a look at command run till now –
    Tutorialwing Android Run or Debug Android App Using Wifi on Real Device Example
  • Save changes done in .bash_profile file. Then, close it.
  • Close terminal
  • Now, open terminal. Go to (~). Then, run adb devices command again. It will show list of devices connected to system –
    Tutorialwing Android Run or Debug Android App Using Wifi on Real Device Example

    There is no connected devices as of now. We will now try to connect a device using wifi.

Connect Device Using Wifi

Till now, we have set path for sdk/tools and sdk/platform-tools location. Now, we will connect device to system using wifi.

Follow steps below to connect device –

  • Check if device is connected to system or not.
    Run below command –

    adb devices
    

    It will empty list.

  • Now, connect android device with laptop using USB cable. Then, run adb devices again. It will show one device now.
  • Now, run below command –
    adb tcpip 5555
    

    Tutorialwing Android Run or Debug Android App Using Wifi Example

  • Now, we may disconnect your android devices from laptop.
  • Next step is to connect adb host with android device using it’s ip address (of phone).
    Find ip address of your phone.
    Then, run below command to connect it with adb host –

    adb connect 192.168.118.103:5555
    

    Replace 192.168.118.103 with ip address of your phone.

  • After running above command, your android device will be connected with adb host. Check below screenshot for reference –
    Tutorialwing Android Run or Debug Android App Using Wifi Example
  • If we run adb devices again, we will see list of devices connected with adb host using tcp-ip now –Tutorialwing install android App wirelessly on phone
  • We have connected android device with adb host. Now, we can use this device to run android app.

Run Android App on Wirelessly connected Android Device

We have already connected our android device with adb host (i.e. Laptop in which we are running android studio). Now, android device should be visible in android studio.
We have already created HelloWorld App. Open this app in android studio. If you have not created yet, visit how to create android app in android studio to create it.

Selected connected android device in android studio. Then, run it. Final output will be like below –

Tutorialwing install android App wirelessly on phone

Final Output

Thus, we learnt how to run or debug android app using wifi on real device.

Leave a Reply