The Android Debug Bridge is an application that runs on a computer to communicate with a USB connected Android device. Begin by changing settings on the Android device, under Developer options, to enable USB debugging. Then connect the device and click OK on the popup seeking permission for remote access. If in the device listing below it says unauthorised
instead of device then the popup on the device has probably not provided the right permissions. Sometimes re-plugging the device will do the trick to show the popup on the device. Show
On Ubuntu install the command line application:
Start up a shell running on the Android device connected via a daemon which is started up if it is not already running: Common GNU/Linux shell commands can now be utilised to navigate the device’s operating system.
Here, Type Ctrl-d or the exit command to exit from the shell. If the daemon is not running it will automatically start up with the message:
In the following circumstance, do as suggested—check for the confirmation dialog on the device:
If your device is not listed then try using an alternative USB cable, which oddly enough can be the problem. This may be because a Samsung cable is required (?) or the old USB cable is functional enough for charging but not communicating. If your device is not rooted you will be limited in what you can access. See https://developer.android.com/studio/command-line/adb for details of using ADB. Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Creative Commons Attribution-ShareAlike 4.0
In this document
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:
You can find the When you start an adb client, the client first checks whether there is an adb server process already running. If there isn't, it starts the server process. When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server. The server then sets up connections to all running emulator/device instances. It locates emulator/device instances by scanning odd-numbered ports in the range 5555 to 5585, the range used by emulators/devices. Where the server finds an adb daemon, it sets up a connection to that port. Note that each emulator/device instance acquires a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for adb connections. For example: Emulator 1, console: 5554 As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554. Once the server has set up connections to all emulator instances, you can use adb commands to access those instances. Because the server manages connections to emulator/device instances and handles commands from multiple adb clients, you can control any emulator/device instance from any client (or from a script). Enabling adb DebuggingIn order to use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options. On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom. On some devices, the Developer options screen may be located or named differently. Note: When you connect a device running Android 4.2.2 or higher to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog. This requires that you have adb version 1.0.31 (available with SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or higher. For more information about connecting to a device over USB, read Using Hardware Devices. SyntaxYou can issue adb commands from a command line on your development machine or from a script. The usage is: adb [-d|-e|-s <serialNumber>] <command> If there's only one emulator running or only one device connected, the adb command is sent to that device by default. If multiple emulators are running and/or multiple devices are attached, you need to use the CommandsThe table below lists all of the supported adb commands and explains their meaning and usage. Table 1. Available adb commands
Querying for Emulator/Device InstancesBefore issuing adb commands, it is helpful to know what emulator/device instances are connected to the adb server. You can generate a list of attached emulators/devices using the adb devices In response, adb prints this status information for each instance:
The output for each instance is formatted like this: [serialNumber] [state] Here's an example showing the adb devices List of devices attached emulator-5554 device emulator-5556 device emulator-5558 device Directing Commands to a Specific Emulator/Device InstanceIf multiple emulator/device instances are running, you must specify a target instance when issuing adb commands. To do
so, use the adb -s <serialNumber> <command> As shown, you specify the target instance for a command using its adb-assigned serial number. You can use the adb -s emulator-5556 install helloWorld.apk Note that, if you issue a command without specifying a target emulator/device instance while multiple devices are available, adb generates an error. If you have multiple
devices available (hardware or emulated), but only one is an emulator, simply use the Installing an ApplicationYou can use adb to copy an application from your development computer and install it on an emulator/device instance. To do so, use the adb install <path_to_apk> For more information about how to create an .apk file that you can install on an emulator/device instance, see Building and Running Note that, if you are using the Eclipse IDE and have the ADT plugin installed, you do not need to use adb (or aapt) directly to install your application on the emulator/device. Instead, the ADT plugin handles the packaging and installation of the application for you. Forwarding PortsYou can use the adb forward tcp:6100 tcp:7100 You can also use adb to set up forwarding to named abstract UNIX domain sockets, as illustrated here: adb forward tcp:6100 local:logd Copying Files to or from an Emulator/Device InstanceYou can use the adb commands To copy a file or directory (and its sub-directories) from the emulator or device, use adb pull <remote> <local> To copy a file or directory (and its sub-directories) to the emulator or device, use adb push <local> <remote> In the commands, adb push foo.txt /sdcard/foo.txt Stopping the adb ServerIn some cases, you might need to terminate the adb server process and then restart it to resolve the problem (e.g., if adb does not respond to a command). To stop the adb server, use the Wireless usageadb is usually used over USB. However, it is also possible to use over Wi-Fi, as described here.
You're now good to go! If the adb connection is ever lost:
Apa gunanya adb?Perintah adb memfasilitasi berbagai tindakan perangkat, seperti menginstal dan men-debug aplikasi, dan memberikan akses ke shell Unix yang dapat Anda gunakan untuk menjalankan berbagai perintah di perangkat.
Apa itu reboot with adb?adb reboot-bootloader – perintah adb ini adalah melakukan proses reboot atau menyalakan ulang android kamu ke mode bootloader. Setelah berada di mode bootloader, perintah adb tidak lagi berfungsi diganti dengan perintah fastboot.
|