How to install APK using ADB commands on your Android

Android Debug Bridge (ADB) is a command-line tool that allows you to interact with an Android device. It enables several system activities, including installing and debugging applications.

There are some additional facilities offered by ADB. ADB belongs to the SDK Platform-Tools package of Android. You can download this package from the SDK Manager, which installs it on android sdk / platform tools /

How does ADB work? 

The linked devices (emulator or actual device connected via USB) can be located when you launch an ADB client. Upon the location of the devices, you can execute ADB commands to monitor certain devices. ADB is part of the Android SDK Platform-Tools kit (if you’ve installed Android Studio).

Read: Apply Update from ADB

adb install apk

Steps to run ADB commands:

While Android Studio has been installed on your Mac, you can run ADB commands in 2 different ways. 

The following steps need to be carried out ADB commands directly from any terminal directory. 

  • Run your terminal with the emacs~/.bash command profile. This opens your profile on the bash profile. Add this line to the — export PATH=”$PATH:/Users / user / Library / Android / sdk / platform-tools “file. Make sure you replace username with the username of Mac (name of the home directory) 
  • Using CTRL+x CTRL+c to save and close the EMac editor. This will ask you to save any changes that have not been saved. Save the changes by typing y. 
  • Run the source~/.bash profile to reload your bash profile. 

Here, the global PATH variable is shifted to the Platform-tools path. This path is used by the computer for all ADB commands. Any ADB command in your terminal can now be executed. 

You must run the ADB commands on your terminal ‘s platform tool folder if you do not want to set the global PATH variable. The ADB executable is usually found in ~/Library / Android / sdk / platform-tools 

Make sure now that all ADB commands are prefixed, for example. /adb devices

You may get an error by not defining an ADB instruction. The above configuration should solve your problem.

How to use it on wireless?

Currently, ADB is transmitted over USB. You can also use over Wi-Fi, however, as described below. 

  1. Link to a common wireless network, both your Android device and the ADB machine. You will need to use an access point with the Firewall properly configured to support ADB; you may find that not all access points are suitable. 

Note: If you’re trying to connect to a Wear device, force it to connect to Wi-Fi by shutting off Bluetooth on your phone. 

  1. Link the device with a USB-cable to the host computer. 
  2. Set target computer on port 5555 for listening to a TCP / IP connection. 

$adb tcpip  5555 

  1. Disconnect the USB cable from the destination device.
  2. Search for the IP address of the Android device. In Settings > On Tablet (or About Phone) > Status > IP Address, you will find, for example, the IP address on a Nexus device. In Settings > Wi-Fi Settings > Advanced > IP Address you can find an IP address on an Android Wear app.
  3. Connect to your device and recognize it by IP address. 

$ adb connect YOUR_PHONE_IP_ADDRESS

  1. Confirm that your host machine has the target device connected: 

$ adb devices

List of devices connected 

:5555 device

If the connection to ADB is lost:  

Join the same WiFi network your host has with your Android app. 

Restart the “adb connect” step by running again. Or if it doesn’t work reset the host ADB to, 

$ adb kill-server

Now start everything step wise from the beginning as mentioned above.

How do I install APK using ADB command on the device/emulator? 

Run command for ADB devices on your terminal. This command prints all the devices and emulators that are connected to your Mac. Here are the sample data that this command prints – 

G070VM0583744P7T device

emulator-5554 device

The serial number of the device is given with its status (offline / device / no-device). In that case, G070VM0583744P7 T is the serial number for Fire TV. You can also run ADB devices -l to learn more about the devices you have connected.

To install your apk on the device, run adb -s <serial number> install <apk path> Make sure that you substitute < serial number > with the device’s actual serial number displayed by command ADB devices. Even the local path of your apk should be replaced by < apk path >. 

Just run adb, install apkname.apk, if you have only one device/emulator connected to your Mac. The apk will only be installed on the connected device.

Now after all the above steps you installed apk file from your computer to the other devices successfully!

Leave a Comment