Android Debug Bridge(ADB) for Android
Android Debug Bridge:
Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator or connected Android device. It is a client-server program that includes three components:
ADB Commands:
The format for issuing commands through the ADB is as follows:
adb [-d|-e|-s <serialNumber>] <command>
Installing an Application:
With the help of adb we can install our app on emulator or device.
adb install <path_to_apk>
where <path_to_apk> is the path of that apk file which you want to install on emulator/device.
Viewing connected Android devices:
To view the attached devices use devices command. It prints a list of all attached emulator/device instances.
adb devices
Here’s an example showing the devices command and its output:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
where emulator-5558 is the serial number and device is the instance that is connected to adb server.
If there is no emulator/device running, adb returns no device.
Sending commands to specific emulator/device:
If multiple emulator/device instances are running, you need to specify a target instance when issuing adb commands.
adb -s <serialNumber> <command>
Example: adb -s emulator-5556 install demo1.apk
Copying Files to or from an Emulator/Device :
You can use the adb commands pull and push to copy files to and from an emulator/device.
If you want to copy a file from the emulator or device you can use pull command.
adb pull <remote> <local>
If you want to copy a file to the emulator or device you can use push command.
adb push <local> <remote>
In the commands, <local> and <remote> refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote).
Starting and killing the server:To start server use,
adb start-server
When the server starts, it binds to local TCP port 5037. All adb clients use port 5037 to communicate with the adb server.
To kill server use kill-server command it kills the already running server.
adb kill-server
Forwarding Ports:
Forward command is used to forward the requests on the specific host port to a different port on emulator/device instance.
adb forward tcp:6100 tcp:7100
Enabling logcat Logging
You can use the logcat command to view log output in your development computer.
adb logcat.
Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator or connected Android device. It is a client-server program that includes three components:
- Client- It runs on your development machine. You can invoke a client from a shell by issuing an adb command.
- Server-It runs as a background process on your development machine. The server manages communication between the client and the adb daemon.
- Daemon- It runs as a background process on each emulator or device instance.
ADB Commands:
The format for issuing commands through the ADB is as follows:
adb [-d|-e|-s <serialNumber>] <command>
Installing an Application:
With the help of adb we can install our app on emulator or device.
adb install <path_to_apk>
where <path_to_apk> is the path of that apk file which you want to install on emulator/device.
Viewing connected Android devices:
To view the attached devices use devices command. It prints a list of all attached emulator/device instances.
adb devices
Here’s an example showing the devices command and its output:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
where emulator-5558 is the serial number and device is the instance that is connected to adb server.
If there is no emulator/device running, adb returns no device.
Sending commands to specific emulator/device:
If multiple emulator/device instances are running, you need to specify a target instance when issuing adb commands.
adb -s <serialNumber> <command>
Example: adb -s emulator-5556 install demo1.apk
Copying Files to or from an Emulator/Device :
You can use the adb commands pull and push to copy files to and from an emulator/device.
If you want to copy a file from the emulator or device you can use pull command.
adb pull <remote> <local>
If you want to copy a file to the emulator or device you can use push command.
adb push <local> <remote>
In the commands, <local> and <remote> refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote).
Starting and killing the server:To start server use,
adb start-server
When the server starts, it binds to local TCP port 5037. All adb clients use port 5037 to communicate with the adb server.
To kill server use kill-server command it kills the already running server.
adb kill-server
Forwarding Ports:
Forward command is used to forward the requests on the specific host port to a different port on emulator/device instance.
adb forward tcp:6100 tcp:7100
Enabling logcat Logging
You can use the logcat command to view log output in your development computer.
adb logcat.
Comments
Post a Comment