Lỗi daemon not running starting it now on port 5037 năm 2024

Mới gần đây khi mày mò thêm về React Native thì mình gặp phải một số lỗi liên quan đến ADB cụ thể như sau:

Khi mình test thử app thì không thể hoạt động được, gặp đủ lỗi linh tính, vì nhiều quá nên mình không kể ra đây được. Khi mình dùng adb devices để xem danh sách thiết bị thì gặp ra thông báo như bên dưới. Search google mãi mới có cách fix nhưng mà cũng chật vật lắm trong khi lỗi rõ ràng kia rồi nên mình đăng cái này mục đích chính là giúp mình nhớ lại thôi, có khi bạn nào vô tình gặp lỗi này mình cũng giúp fix một tay chứ sau này chết ốm mình không tìm lại được mất.

adb server version (39) doesn’t match this client (36); killing… error: could not install *smartsocket* listener: Address already in use ADB server didn’t ACK * failed to start daemon *

và lỗi này

adb server is out of date. killing… cannot bind ‘tcp:5037’ ADB server didn’t ACK * failed to start daemon *

Cách fix như sau: Bạn bật command lên và chạy lần lượt nhé, nếu cái nào không được thì thêm sudo đằng trước để chạy với quyền super user

cp /Android/Sdk/platform-tools/adb /usr/bin/adb chmod +x /usr/bin/adb nano /etc/environment source /.bashrc

Cá nhân mình vẫn chưa thực sự hiểu nguyên nhân lắm nhưng vẫn copy ra đây cho các bạn đọc. Bạn nào muốn đọc chi tiết hơn có thể xem tại đây còn cách fix thì ở link này

If you have adb installed as part of your Linux distribution, then your PATH probably points there. Chances are this adb is version 1.0.31 (or earlier).

Genymotion comes with its own adb in the tools/ directory, which is version 1.0.32 if you are running the latest Genymotion, currently 2.3.1. Unless you changed it in the settings, Genymotion will start the bridge with that copy.

Since adb operates in a client-server arrangement, the client version should match the daemon version. In your case, they don’t and that’s why you’re getting the adb server is out of date. killing… message. If the daemon is killed or dies, the Genymotion launcher automatically and immediately restarts adb (using its own copy), and that’s why your client can’t start a new daemon bound to port 5037.

The solution is to make sure that the version of adb you are invoking on the command line matches the one that Genymotion is bringing up as a daemon when it starts the VMs. The easiest way to ensure this is just to use the adb binary in Genymotion’s tools/ directory.

Note that if you have changed Genymotion’s default of using its own tools to use custom SDK tools, then you’ll need to use an adb client that matches the version contained in the SDK you’re pointing to. As far as I can tell, KitKat (4.4.4) and earlier SDKs contain adb version 1.0.31, while the Lollipop (5.0) SDKs have 1.0.32.

Hôm nay mình có làm theo video hướng dẫn up phiên bản 4.4.2 kitkat cho zenfone 5 từ trang sforum.vn của cellphone thì mình phát hiện máy mình bị lỗi: Daemon not running. starting it now on port 5037. hy vọng được các bạn chỉ cách khắc phục để có thể up phiên bản.

Android Debug Bridge (

adb kill-server

  1. is a versatile command-line tool that lets you communicate with a device. The

adb kill-server

7 command facilitates a variety of device actions, such as installing and debugging apps.

adb kill-server

7 provides access to a Unix shell that you can use to run a variety of commands on a device. It is a client-server program that includes three components:

  • A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb kill-server 7 command.
  • A daemon (adbd), which runs commands on a device. The daemon runs as a background process on each device.
  • A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.

adb kill-server

7 is included in the Android SDK Platform Tools package. Download this package with the , which installs it at

adb devices -l

2. If you want the standalone Android SDK Platform Tools package, download it here.

For information on connecting a device for use over

adb kill-server

7, including how to use the Connection Assistant to troubleshoot common problems, see Run apps on a hardware device.

How adb works

When you start an

adb kill-server

7 client, the client first checks whether there is an

adb kill-server

7 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 kill-server

7 clients.

Note: All

adb kill-server

7 clients use port 5037 to communicate with the

adb kill-server

7 server.

The server then sets up connections to all running devices. It locates emulators by scanning odd-numbered ports in the range 5555 to 5585, which is the range used by the first 16 emulators. Where the server finds an

adb kill-server

7 daemon (adbd), it sets up a connection to that port.

Each emulator uses a pair of sequential ports — an even-numbered port for console connections and an odd-numbered port for

adb kill-server

7 connections. For example:

Emulator 1, console: 5554 Emulator 1,

adb kill-server

7: 5555 Emulator 2, console: 5556 Emulator 2,

adb kill-server

7: 5557 and so on.

As shown, the emulator connected to

adb kill-server

7 on port 5555 is the same as the emulator whose console listens on port 5554.

Once the server has set up connections to all devices, you can use

adb kill-server

7 commands to access those devices. Because the server manages connections to devices and handles commands from multiple

adb kill-server

7 clients, you can control any device from any client or from a script.

Enable adb debugging on your device

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 (API level 17) and higher, the Developer options screen is hidden by default. To make it visible,

You can now connect your device with USB. You can verify that your device is connected by executing

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 from the

adb devices -l

2 directory. If connected, you'll see the device name listed as a "device."

Note: When you connect a device running Android 4.2.2 (API level 17) or higher, 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.

For more information about connecting to a device over USB, read Run apps on a hardware device.

Connect to a device over Wi-Fi

Note: The instructions below do not apply to Wear devices running Android 11 (API level 30). See the guide to for more information.

Android 11 (API level 30) and higher support deploying and debugging your app wirelessly from your workstation using Android Debug Bridge (adb). For example, you can deploy your debuggable app to multiple remote devices without ever needing to physically connect your device via USB. This eliminates the need to deal with common USB connection issues, such as driver installation.

Before you begin using wireless debugging, do the following:

  • Ensure that your workstation and device are connected to the same wireless network.
  • Ensure that your device is running Android 11 (API level 30) or higher for phone or Android 13 (API level 33) or higher for TV and WearOS. For more information, see Check & update your Android version.
  • If using the IDE, ensure that you have the latest version of Android Studio installed. You can download it here.
  • On your workstation, update to the latest version of the SDK Platform Tools.

To use wireless debugging, you must pair your device to your workstation using a QR code or a pairing code. Your workstation and device must be connected to the same wireless network. To connect to your device, follow these steps:

  1. on your device.
  2. Open Android Studio and select Pair Devices Using Wi-Fi from the run configurations menu.
    Lỗi daemon not running starting it now on port 5037 năm 2024
    Figure 1. Run configurations menu. The Pair devices over Wi-Fi window pops up, as shown in figure 2.
    Lỗi daemon not running starting it now on port 5037 năm 2024
    Figure 2. Popup window to pair devices using QR code or pairing code.
  3. On your device, tap Wireless debugging and pair your device:

    ![Screenshot of

            a pixel phone showing the Wireless debugging systems setting.](https://https://i0.wp.com/developer.android.com/static/studio/images/run/adb_wifi-wireless_debugging.png)  
    
    Figure 3. Screenshot of the Wireless debugging setting on a Google Pixel phone.

    1. To pair your device with a QR code, select Pair device with QR code and scan the QR code obtained from the Pair devices over Wi-Fi popup shown in figure 2.
    2. To pair your device with a pairing code, select Pair device with pairing code from the Pair devices over Wi-Fi popup. On your device, select Pair using pairing code and take note of the six-digit code provided. Once your device appears on the Pair devices over Wi-Fi window, you can select Pair and enter the six-digit code shown on your device.
      Lỗi daemon not running starting it now on port 5037 năm 2024
      Figure 4. Example of six-digit code entry.
  4. After your device is paired, you can attempt to deploy your app to your device. To pair a different device or to forget the current device on your workstation, navigate to Wireless debugging on your device. Tap your workstation name under Paired devices and select Forget.
  5. If you want to quickly turn on and off wireless debugging, you can utilize the for Wireless debugging, found in Developer Options > Quick settings developer tiles. ![Screenshot of
            Quick settings developer tiles from a Google Pixel phone.](https://https://i0.wp.com/developer.android.com/static/studio/images/run/adb_wifi-quick_settings.png)  
    
    Figure 5. The Quick settings developer tiles setting lets you quickly turn wireless debugging on and off.

Wi-Fi connection using command line

Alternatively, to connect to your device using command line without Android Studio, follow these steps:

  1. Enable developer options on your device, as described earlier.
  2. Enable Wireless debugging on your device, as described earlier.
  3. On your workstation, open a terminal window and navigate to $ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo 8.
  4. Find your IP address, port number, and pairing code by selecting Pair device with pairing code. Take note of the IP address, port number, and pairing code displayed on the device.
  5. On your workstation's terminal, run $ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo 9. Use the IP address and port number from above.
  6. When prompted, enter the pairing code, as shown below. ![Screenshot of
            pairing on the command line.](https://https://i0.wp.com/developer.android.com/static/studio/images/run/adb_wifi-cmd_line_pairing.png)  
    
    Figure 6. A message indicates that your device has been successfully paired.

Resolve wireless connection issues

If you are having issues connecting to your device wirelessly, try the following troubleshooting steps to resolve the issue.

Check whether your workstation and device meet the prerequisites

Check that the workstation and device meet the prerequisites listed at the .

Check for other known issues

The following is a list of current known issues with wireless debugging (with adb or Android Studio) and how to resolve them:

  • Wi-Fi is not connecting: Secure Wi-Fi networks, such as corporate Wi-Fi networks, may block p2p connections and not let you connect over Wi-Fi. Try connecting with a cable or another (non-corp) Wi-Fi network. Wireless connection using $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5555 $ adb devices List of devices attached
  • daemon not running. starting it now on port 5037 *
  • daemon started successfully * 0 over tcp/ip (following an initial USB connection) is another option, in case resorting to a non-corp network is an option.
  • adb kill-server 7 over Wi-Fi sometimes turns off automatically: This can happen if the device either switches Wi-Fi networks or disconnects from the network. To resolve, re-connect to the network.
  • Device not connecting after pairing successfully: adb kill-server 7 relies on mDNS to discover and automatically connect to paired devices. If your network or device configuration does not support mDNS or has disabled it, then you need to manually connect to the device using $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5555 $ adb devices List of devices attached
  • daemon not running. starting it now on port 5037 *
  • daemon started successfully * 0.

Connect wirelessly with a device after an initial USB connection (only option available on Android 10 and lower)

Note: This workflow is applicable also to Android 11 (and higher), the caveat being that it also involves an *initial* connection over physical USB.

Note: The following instructions do not apply to Wear devices running Android 10 (API level 29) or lower. See the guide about for more information.

adb kill-server

7 usually communicates with the device over USB, but you can also use

adb kill-server

7 over Wi-Fi. To connect a device running Android 10 (API level 29) or lower, follow these initial steps over USB:

  1. Connect your Android device and adb kill-server 7 host computer to a common Wi-Fi network.

Note: Beware that not all access points are suitable. You might need to use an access point whose firewall is configured properly to support

adb kill-server

7.

  1. Connect the device to the host computer with a USB cable.
  2. Set the target device to listen for a TCP/IP connection on port 5555: adb tcpip 5555
  3. Disconnect the USB cable from the target device.
  4. Find the IP address of the Android device. For example, on a Nexus device, you can find the IP address at Settings > About tablet (or About phone) > Status > IP address.
  5. Connect to the device by its IP address: adb connect device_ip_address:5555
  6. Confirm that your host computer is connected to the target device: $ adb devices List of devices attached device_ip_address:5555 device

Your device is now connected to

adb kill-server

7.

If the

adb kill-server

7 connection to your device is lost:

  • Make sure that your host is still connected to the same Wi-Fi network as your Android device.
  • Reconnect by executing the $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device 0 step again.
  • If that doesn't work, reset your adb kill-server 7 host: adb kill-server Then start over from the beginning.

Query for devices

Before issuing

adb kill-server

7 commands, it is helpful to know what device instances are connected to the

adb kill-server

7 server. Generate a list of attached devices using the

$ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device

4 command:

adb devices -l

In response,

adb kill-server

7 prints this status information for each device:

  • Serial number: adb kill-server 7 creates a string to uniquely identify the device by its port number. Here's an example serial number: $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device 7
  • State: The connection state of the device can be one of the following:
    • $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device 8: The device is not connected to adb kill-server 7 or is not responding.
    • $ adb devices

      List of devices attached emulator-5554 device emulator-5555 device 0.0.0.0:6520 device

      To install on emulator-5555

      $ adb -s emulator-5555 install helloWorld.apk

      To install on 0.0.0.0:6520

      $ adb -s 0.0.0.0:6520 install helloWorld.apk 0: The device is connected to the adb kill-server 7 server. Note that this state does not imply that the Android system is fully booted and operational, because the device connects to adb kill-server 7 while the system is still booting. After boot-up, this is the normal operational state of a device.
    • $ adb devices

      List of devices attached emulator-5554 device emulator-5555 device 0.0.0.0:6520 device

      To install on emulator-5555

      $ adb -s emulator-5555 install helloWorld.apk

      To install on 0.0.0.0:6520

      $ adb -s 0.0.0.0:6520 install helloWorld.apk 3: There is no device connected.
  • Description: If you include the

    $ adb devices List of devices attached emulator-5554 device emulator-5555 device 0.0.0.0:6520 device

    To install on emulator-5555

    $ adb -s emulator-5555 install helloWorld.apk

    To install on 0.0.0.0:6520

    $ adb -s 0.0.0.0:6520 install helloWorld.apk 4 option, the $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device 4 command tells you what the device is. This information is helpful when you have multiple devices connected so that you can tell them apart.

The following example shows the

$ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device

4 command and its output. There are three devices running. The first two lines in the list are emulators, and the third line is a hardware device that is attached to the computer.

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

Emulator not listed

The

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 command has a corner-case command sequence that causes running emulators to not show up in the

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 output even though the emulators are visible on your desktop. This happens when all of the following conditions are true:

  • The adb kill-server 7 server is not running.
  • You use the adb install path_to_apk 0 command with the adb install path_to_apk 1 or adb install path_to_apk 2 option with an odd-numbered port value between 5554 and 5584.
  • The odd-numbered port you chose is not busy, so the port connection can be made at the specified port number — or, if it is busy, the emulator switches to another port that meets the requirements in 2.
  • You start the adb kill-server 7 server after you start the emulator.

One way to avoid this situation is to let the emulator choose its own ports and to run no more than 16 emulators at once. Another way is to always start the

adb kill-server

7 server before you use the

adb install path_to_apk

0 command, as explained in the following examples.

Example 1: In the following command sequence, the

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 command starts the

adb kill-server

7 server, but the list of devices does not appear.

Stop the

adb kill-server

7 server and enter the following commands in the order shown. For the AVD name, provide a valid AVD name from your system. To get a list of AVD names, type

adb install path_to_apk

9. The

adb install path_to_apk

0 command is in the

adb connect device_ip_address:5555

01 directory.

$ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5555 $ adb devices List of devices attached

  • daemon not running. starting it now on port 5037 *
  • daemon started successfully *

Example 2: In the following command sequence,

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 displays the list of devices because the

adb kill-server

7 server was started first.

To see the emulator in the

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 output, stop the

adb kill-server

7 server, and then start it again after using the

adb install path_to_apk

0 command and before using the

$ adb devices List of devices attached emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64 emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86 0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo

6 command, as follows:

$ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device

For more information about emulator command-line options, see .

Send commands to a specific device

If multiple devices are running, you must specify the target device when you issue the

adb kill-server

7 command. To specify the target, follow these steps:

  1. Use the $ adb kill-server $ emulator -avd Nexus_6_API_25 -port 5557 $ adb start-server $ adb devices List of devices attached emulator-5557 device 4 command to get the serial number of the target.
  2. Once you have the serial number, use the

    adb connect device_ip_address:5555 10 option with the adb kill-server 7 commands to specify the serial number.

    1. If you're going to issue a lot of adb kill-server 7 commands, you can set the adb connect device_ip_address:5555 13 environment variable to contain the serial number instead.
    2. If you use both adb connect device_ip_address:5555 10 and adb connect device_ip_address:5555 13, adb connect device_ip_address:5555 10 overrides adb connect device_ip_address:5555 13.

In the following example, the list of attached devices is obtained, and then the serial number of one of the devices is used to install the

adb connect device_ip_address:5555

18 on that device:

$ adb devices List of devices attached emulator-5554 device emulator-5555 device 0.0.0.0:6520 device

To install on emulator-5555

$ adb -s emulator-5555 install helloWorld.apk

To install on 0.0.0.0:6520

$ adb -s 0.0.0.0:6520 install helloWorld.apk

Note: If you issue a command without specifying a target device when multiple devices are available,

adb kill-server

7 displays an error "adb: more than one device/emulator".

If you have multiple devices available but only one is an emulator, use the

adb connect device_ip_address:5555

20 option to send commands to the emulator. If there are multiple devices but only one hardware device attached, use the

adb connect device_ip_address:5555

21 option to send commands to the hardware device.

Install an app

You can use

adb kill-server

7 to install an APK on an emulator or connected device with the

adb connect device_ip_address:5555

23 command:

adb install path_to_apk

You must use the

adb connect device_ip_address:5555

24 option with the

adb connect device_ip_address:5555

23 command when you install a test APK. For more information, see .

To install multiple APKs use

adb connect device_ip_address:5555

27. This is useful if you download all the APKs for a specific device for your app from the Play Console and want to install them on an emulator or physical device.

For more information about how to create an APK file that you can install on an emulator/device instance, see Build and run your app.

Note: If you are using Android Studio, you do not need to use

adb kill-server

7 directly to install your app on the emulator or device. Instead, Android Studio handles the packaging and installation of the app for you.

Set up port forwarding

Use the

adb connect device_ip_address:5555

29 command to set up arbitrary port forwarding, which forwards requests on a specific host port to a different port on a device. The following example sets up forwarding of host port 6100 to device port 7100:

adb connect device_ip_address:5555

0

The following example sets up forwarding of host port 6100 to local:logd:

adb connect device_ip_address:5555

1

This could be useful if you are trying to detemine what is being sent to a given port on the device. All received data will be written to the system-logging daemon and displayed in the device logs.

Copy files to and from a device

Use the

adb connect device_ip_address:5555

30 and

adb connect device_ip_address:5555

31 commands to copy files to and from a device. Unlike the

adb connect device_ip_address:5555

23 command, which only copies an APK file to a specific location, the

adb connect device_ip_address:5555

30 and

adb connect device_ip_address:5555

31 commands let you copy arbitrary directories and files to any location in a device.

To copy a file or directory and its sub-directories from the device, do the following:

adb connect device_ip_address:5555

2

To copy a file or directory and its sub-directories to the device, do the following:

adb connect device_ip_address:5555

3

Replace

adb connect device_ip_address:5555

35 and

adb connect device_ip_address:5555

36 with the paths to the target files/directory on your development machine (local) and on the device (remote). For example:

adb connect device_ip_address:5555

4

Stop the adb server

In some cases, you might need to terminate the

adb kill-server

7 server process and then restart it to resolve the problem. For example, this could be the case if

adb kill-server

7 does not respond to a command.

To stop the

adb kill-server

7 server, use the

adb connect device_ip_address:5555

40 command. You can then restart the server by issuing any other

adb kill-server

7 command.

Issue adb commands

Issue

adb kill-server

7 commands from a command line on your development machine or from a script using the following:

adb connect device_ip_address:5555

5

If there's only one emulator running or only one device connected, the

adb kill-server

7 command is sent to that device by default. If multiple emulators are running and/or multiple devices are attached, you need to use the

adb connect device_ip_address:5555

21,

adb connect device_ip_address:5555

20, or

adb connect device_ip_address:5555

10 option to specify the target device to which the command should be directed.

You can see a detailed list of all supported

adb kill-server

7 commands using the following command:

adb connect device_ip_address:5555

6

Issue shell commands

You can use the

adb connect device_ip_address:5555

48 command to issue device commands through

adb kill-server

7 or to start an interactive shell. To issue a single command, use the

adb connect device_ip_address:5555

48 command like this:

adb connect device_ip_address:5555

7

To start an interactive shell on a device, use the

adb connect device_ip_address:5555

48 command like this:

adb connect device_ip_address:5555

8

To exit an interactive shell, press

adb connect device_ip_address:5555

52 or type

adb connect device_ip_address:5555

53.

Android provides most of the usual Unix command-line tools. For a list of available tools, use the following command:

adb connect device_ip_address:5555

9

Help is available for most of the commands via the

adb connect device_ip_address:5555

54 argument. Many of the shell commands are provided by toybox. General help applicable to all toybox commands is available via

adb connect device_ip_address:5555

55.

With Android Platform Tools 23 and higher,

adb kill-server

7 handles arguments the same way that the

adb connect device_ip_address:5555

57 command does. This change has fixed a lot of problems with and makes it possible to safely execute commands that contain shell metacharacters, such as

adb connect device_ip_address:5555

58. This change means that the interpretation of any command that contains shell metacharacters has also changed.

For example,

adb connect device_ip_address:5555

59 is now an error, because the single quotes (

adb connect device_ip_address:5555

  1. are swallowed by the local shell, and the device sees

adb connect device_ip_address:5555

61. To make the command work, quote twice, once for the local shell and once for the remote shell, as you do with

adb connect device_ip_address:5555

57. For example,

adb connect device_ip_address:5555

63.

See also Logcat command-line tool, which is useful for monitoring the system log.

Call activity manager

Within an

adb kill-server

7 shell, you can issue commands with the activity manager (

adb connect device_ip_address:5555

  1. tool to perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties, and more.

While in a shell, the

adb connect device_ip_address:5555

65 syntax is:

$ adb devices List of devices attached device_ip_address:5555 device

0

You can also issue an activity manager command directly from

adb kill-server

7 without entering a remote shell. For example:

$ adb devices List of devices attached device_ip_address:5555 device

1

Table 1. Available activity manager commands

Command Description

adb connect device_ip_address:5555

68 Start an

adb connect device_ip_address:5555

69 specified by

adb connect device_ip_address:5555

70.

See the .

Options are:

  • adb connect device_ip_address:5555 71: Enable debugging.
  • adb connect device_ip_address:5555 72: Wait for launch to complete.
  • adb connect device_ip_address:5555 73: Start profiler and send results to adb connect device_ip_address:5555 74.
  • adb connect device_ip_address:5555 75: Like adb connect device_ip_address:5555 76, but profiling stops when the app goes idle.
  • adb connect device_ip_address:5555 77: Repeat the activity launch adb connect device_ip_address:5555 78 times. Prior to each repeat, the top activity will be finished.
  • adb connect device_ip_address:5555 79: Force stop the target app before starting the activity.
  • adb connect device_ip_address:5555 80: Enable tracing of OpenGL functions.
  • adb connect device_ip_address:5555 81: Specify which user to run as; if not specified, then run as the current user.

adb connect device_ip_address:5555

82 Start the

adb connect device_ip_address:5555

83 specified by

adb connect device_ip_address:5555

70.

See the .

Options are:

  • adb connect device_ip_address:5555 81: Specify which user to run as. If not specified, then run as the current user.

adb connect device_ip_address:5555

86 Force-stop everything associated with

adb connect device_ip_address:5555

87.

adb connect device_ip_address:5555

88 Kill all processes associated with

adb connect device_ip_address:5555

87. This command kills only processes that are safe to kill and that will not impact the user experience.

Options are:

  • adb connect device_ip_address:5555 90: Specify which user's processes to kill. If not specified, then kill all users' processes.

adb connect device_ip_address:5555

91 Kill all background processes.

adb connect device_ip_address:5555

92 Issue a broadcast intent.

See the .

Options are:

  • adb connect device_ip_address:5555 93: Specify which user to send to. If not specified, then send to all users.

adb connect device_ip_address:5555

94 Start monitoring with an

adb connect device_ip_address:5555

95 instance. Typically the target

adb connect device_ip_address:5555

96 is the form

adb connect device_ip_address:5555

97.

Options are:

  • adb connect device_ip_address:5555 98: Print raw results (otherwise decode adb connect device_ip_address:5555 99). Use with $ adb devices List of devices attached device_ip_address:5555 device 00 to generate raw output for performance measurements.
  • $ adb devices List of devices attached device_ip_address:5555 device 01: Set argument $ adb devices List of devices attached device_ip_address:5555 device 02 to $ adb devices List of devices attached device_ip_address:5555 device 03. For test runners a common form is $ adb devices List of devices attached device_ip_address:5555 device 04.
  • $ adb devices List of devices attached device_ip_address:5555 device 05: Write profiling data to adb connect device_ip_address:5555 74.
  • $ adb devices List of devices attached device_ip_address:5555 device 07: Wait for instrumentation to finish before returning. Required for test runners.
  • $ adb devices List of devices attached device_ip_address:5555 device 08: Turn off window animations while running.
  • adb connect device_ip_address:5555 81: Specify which user instrumentation runs in. If not specified, run in the current user.

$ adb devices List of devices attached device_ip_address:5555 device

10 Start profiler on

$ adb devices List of devices attached device_ip_address:5555 device

11, write results to

adb connect device_ip_address:5555

74.

$ adb devices List of devices attached device_ip_address:5555 device

13 Stop profiler on

$ adb devices List of devices attached device_ip_address:5555 device

11.

$ adb devices List of devices attached device_ip_address:5555 device

15 Dump the heap of

$ adb devices List of devices attached device_ip_address:5555 device

11, write to

adb connect device_ip_address:5555

74.

Options are:

  • $ adb devices List of devices attached device_ip_address:5555 device 18: When supplying a process name, specify the user of the process to dump. If not specified, the current user is used.
  • $ adb devices List of devices attached device_ip_address:5555 device 19: Dump native heap instead of managed heap.

$ adb devices List of devices attached device_ip_address:5555 device

20 Set app

adb connect device_ip_address:5555

87 to debug.

Options are:

  • $ adb devices List of devices attached device_ip_address:5555 device 07: Wait for debugger when app starts.
  • $ adb devices List of devices attached device_ip_address:5555 device 23: Retain this value.

$ adb devices List of devices attached device_ip_address:5555 device

24 Clear the package previous set for debugging with

$ adb devices List of devices attached device_ip_address:5555 device

25.

$ adb devices List of devices attached device_ip_address:5555 device

26 Start monitoring for crashes or ANRs.

Options are:

  • $ adb devices List of devices attached device_ip_address:5555 device 27: Start $ adb devices List of devices attached device_ip_address:5555 device 28 on the given port at crash/ANR.

$ adb devices List of devices attached device_ip_address:5555 device

29 Control screen compatibility mode of

adb connect device_ip_address:5555

87.

$ adb devices List of devices attached device_ip_address:5555 device

31 Override device display size. This command is helpful for testing your app across different screen sizes by mimicking a small screen resolution using a device with a large screen, and vice versa.

Example:

$ adb devices List of devices attached device_ip_address:5555 device

32

$ adb devices List of devices attached device_ip_address:5555 device

33 Override device display density. This command is helpful for testing your app across different screen densities by mimicking a high-density screen environment using a low-density screen, and vice versa.

Example:

$ adb devices List of devices attached device_ip_address:5555 device

34

$ adb devices List of devices attached device_ip_address:5555 device

35 Print the given intent specification as a URI.

See the .

$ adb devices List of devices attached device_ip_address:5555 device

36 Print the given intent specification as an

$ adb devices List of devices attached device_ip_address:5555 device

37 URI.

See the .

Specification for intent arguments

For activity manager commands that take an

adb connect device_ip_address:5555

70 argument, you can specify the intent with the following options:

Show all

$ adb devices List of devices attached device_ip_address:5555 device

39 Specify the intent action, such as

$ adb devices List of devices attached device_ip_address:5555 device

40. You can declare this only once.

$ adb devices List of devices attached device_ip_address:5555 device

41 Specify the intent data URI, such as

$ adb devices List of devices attached device_ip_address:5555 device

42. You can declare this only once.

$ adb devices List of devices attached device_ip_address:5555 device

43 Specify the intent MIME type, such as

$ adb devices List of devices attached device_ip_address:5555 device

44. You can declare this only once.

$ adb devices List of devices attached device_ip_address:5555 device

45 Specify an intent category, such as

$ adb devices List of devices attached device_ip_address:5555 device

46.

$ adb devices List of devices attached device_ip_address:5555 device

47 Specify the component name with package name prefix to create an explicit intent, such as

$ adb devices List of devices attached device_ip_address:5555 device

48.

$ adb devices List of devices attached device_ip_address:5555 device

49 Add flags to the intent, as supported by

$ adb devices List of devices attached device_ip_address:5555 device

50.

$ adb devices List of devices attached device_ip_address:5555 device

51 Add a null extra. This option is not supported for URI intents.

$ adb devices List of devices attached device_ip_address:5555 device

52 Add string data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

53 Add boolean data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

54 Add integer data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

55 Add long data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

56 Add float data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

57 Add URI data as a key-value pair.

$ adb devices List of devices attached device_ip_address:5555 device

58 Add a component name, which is converted and passed as a

$ adb devices List of devices attached device_ip_address:5555 device

59 object.

$ adb devices List of devices attached device_ip_address:5555 device

60 Add an array of integers.

$ adb devices List of devices attached device_ip_address:5555 device

61 Add an array of longs.

$ adb devices List of devices attached device_ip_address:5555 device

62 Add an array of floats.

$ adb devices List of devices attached device_ip_address:5555 device

63 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

64.

$ adb devices List of devices attached device_ip_address:5555 device

65 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

66.

$ adb devices List of devices attached device_ip_address:5555 device

67 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

68.

$ adb devices List of devices attached device_ip_address:5555 device

69 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

70.

$ adb devices List of devices attached device_ip_address:5555 device

71 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

72.

$ adb devices List of devices attached device_ip_address:5555 device

73 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

74.

$ adb devices List of devices attached device_ip_address:5555 device

75 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

76.

$ adb devices List of devices attached device_ip_address:5555 device

77 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

78.

$ adb devices List of devices attached device_ip_address:5555 device

79 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

80.

$ adb devices List of devices attached device_ip_address:5555 device

81 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

82.

$ adb devices List of devices attached device_ip_address:5555 device

83 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

84.

$ adb devices List of devices attached device_ip_address:5555 device

85 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

86.

$ adb devices List of devices attached device_ip_address:5555 device

87 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

88.

$ adb devices List of devices attached device_ip_address:5555 device

89 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

90.

$ adb devices List of devices attached device_ip_address:5555 device

91 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

92.

$ adb devices List of devices attached device_ip_address:5555 device

93 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

94.

$ adb devices List of devices attached device_ip_address:5555 device

95 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

96.

$ adb devices List of devices attached device_ip_address:5555 device

97 Include the flag

$ adb devices List of devices attached device_ip_address:5555 device

98.

$ adb devices List of devices attached device_ip_address:5555 device

99 Include the flag

adb kill-server

00.

adb kill-server

01 Include the flag

adb kill-server

02.

adb kill-server

03 Include the flag

adb kill-server

04.

adb kill-server

05 Include the flag

adb kill-server

06.

adb kill-server

07 Requires the use of

adb connect device_ip_address:5555

21 and

adb connect device_ip_address:5555

24 options to set the intent data and type.

adb kill-server

10 You can directly specify a URI, package name, and component name when not qualified by one of the preceding options. When an argument is unqualified, the tool assumes the argument is a URI if it contains a ":" (colon). The tools assumes the argument is a component name if it contains a "/" (forward-slash); otherwise it assumes the argument is a package name.

Call package manager (

adb kill-server

11)

Within an

adb kill-server

7 shell, you can issue commands with the package manager (

adb kill-server

  1. tool to perform actions and queries on app packages installed on the device.

While in a shell, the

adb kill-server

11 syntax is:

$ adb devices List of devices attached device_ip_address:5555 device

2

You can also issue a package manager command directly from

adb kill-server

7 without entering a remote shell. For example:

$ adb devices List of devices attached device_ip_address:5555 device

3

Table 2. Available package manager commands

Command Description

adb kill-server

16 Print all packages, optionally only those whose package name contains the text in

adb kill-server

17.

Options:

  • adb kill-server 18: See associated file.
  • adb connect device_ip_address:5555 21: Filter to only show disabled packages.
  • adb connect device_ip_address:5555 20: Filter to only show enabled packages.
  • adb connect device_ip_address:5555 10: Filter to only show system packages.
  • adb kill-server 22: Filter to only show third-party packages.
  • adb kill-server 23: See the installer for the packages.
  • adb kill-server 24: Include uninstalled packages.
  • adb kill-server 25: The user space to query.

adb kill-server

26 Print all known permission groups.

adb kill-server

27 Print all known permissions, optionally only those in

adb kill-server

28.

Options:

  • adb kill-server 29: Organize by group.
  • adb kill-server 18: Print all information.
  • adb connect device_ip_address:5555 10: Short summary.
  • adb connect device_ip_address:5555 21: Only list dangerous permissions.
  • adb kill-server 24: List only the permissions users will see.

adb kill-server

34 List all test packages.

Options:

  • adb kill-server 18: List the APK file for the test package.
  • adb kill-server 36: List test packages for only this app.

adb kill-server

37 Print all features of the system.

adb kill-server

38 Print all the libraries supported by the current device.

adb kill-server

39 Print all users on the system.

adb kill-server

40 Print the path to the APK of the given

adb connect device_ip_address:5555

87.

adb kill-server

42 Install a package, specified by

adb kill-server

43, to the system.

Options:

  • adb connect device_ip_address:5555 98: Reinstall an existing app, keeping its data.
  • adb connect device_ip_address:5555 24: Allow test APKs to be installed. Gradle generates a test APK when you have only run or debugged your app or have used the Android Studio Build > Build APK command. If the APK is built using a developer preview SDK, you must include the with the adb connect device_ip_address:5555 23 command if you are installing a test APK.
  • adb kill-server 48: Specify the installer package name.
  • adb kill-server

    49: Set the install location using one of the following values:

    • adb kill-server 50: Use the default install location.
    • adb kill-server 51: Install on internal device storage.
    • adb kill-server 52: Install on external media.
  • adb kill-server 18: Install package on the internal system memory.
  • adb connect device_ip_address:5555 21: Allow version code downgrade.
  • adb kill-server 29: Grant all permissions listed in the app manifest.
  • adb kill-server 56: Quickly update an installed package by only updating the parts of the APK that changed.
  • adb kill-server 57: Installs enough of the APK to launch the app while streaming the remaining data in the background. To use this feature, you must sign the APK, create an , and place this file in the same directory as the APK. This feature is only supported on certain devices. This option forces adb kill-server 7 to use the feature or fail if it is not supported, with verbose information on why it failed. Append the adb kill-server 59 option to wait until the APK is fully installed before granting access to the APK. adb kill-server 60 prevents adb kill-server 7 from using this feature.

adb kill-server

62 Removes a package from the system.

Options:

  • adb kill-server 63: Keep the data and cache directories after package removal.
  • adb kill-server 25: Specifies the user for whom the package is removed.
  • adb kill-server 65: Only uninstalls if the app has the given version code.

adb kill-server

66 Delete all data associated with a package.

adb kill-server

67 Enable the given package or component (written as "package/class").

adb kill-server

68 Disable the given package or component (written as "package/class").

adb kill-server

69

Options:

  • adb kill-server 25: The user to disable.

adb kill-server

71 Grant a permission to an app. On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.

adb kill-server

72 Revoke a permission from an app. On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.

adb kill-server

73 Change the default install location. Location values:

  • adb kill-server 50: Auto: Let system decide the best location.
  • adb kill-server 51: Internal: Install on internal device storage.
  • adb kill-server 52: External: Install on external media.

Note: This is only intended for debugging. Using this can cause apps to break and other undesireable behavior.

adb kill-server

77 Returns the current install location. Return values:

  • adb kill-server 78: Let system decide the best location
  • adb kill-server 79: Install on internal device storage
  • adb kill-server 80: Install on external media

adb kill-server

81 Specify whether the given permission should be enforced.

adb kill-server

82 Trim cache files to reach the given free space.

adb kill-server

83 Create a new user with the given

adb kill-server

84, printing the new user identifier of the user.

adb kill-server

85 Remove the user with the given

adb kill-server

86, deleting all data associated with that user

adb kill-server

87 Print the maximum number of users supported by the device.

adb kill-server

88

Print the domain verification state for the given package, or for all packages if none is specified. State codes are defined as follows:

  • adb kill-server 89: nothing has been recorded for this domain
  • adb kill-server 90: the domain has been successfully verified
  • adb kill-server 91: force-approved, usually through shell
  • adb kill-server 92: force-denied, usually through shell
  • adb kill-server 93: preserved verification from a legacy response
  • adb kill-server 94: preserved verification from a user data restore
  • adb kill-server 95: rejected by a legacy verifier, unknown reason
  • adb kill-server 96: automatically approved by the device config
  • adb kill-server 97: custom error code, which is specific to the device verifier

Options are:

  • adb kill-server 25: include user selections. Include all domains, not just autoVerify ones.

adb kill-server

99

Reset domain verification state for the given package, or for all packages if none is specified.

  • adb connect device_ip_address:5555 87: the package to reset, or "all" to reset all packages

Options are:

  • adb kill-server 25: include user selections. Include all domains, not just autoVerify ones.

adb devices -l

02

Broadcast a verification request for the given package, or for all packages if none is specified. Only sends if the package has previously not recorded a response.

  • adb devices -l
    
    
    03: send even if the package has recorded a response

adb devices -l

04

Manually set the state of a domain for a package. The domain must be declared by the package as autoVerify for this to work. This command will not report a failure for domains that could not be applied.

  • adb devices -l
    
    
    05: the package to set, or "all" to set all packages
  • adb devices -l
    
    
    06: the code to set the domains to. Valid values are:
    • adb devices -l
           
      
      07: reset as if no response was ever recorded.
    • adb devices -l
           
      
      08: treat domain as successfully verified by domain verification agent. Note that the domain verification agent can override this.
    • adb devices -l
           
      
      09: treat domain as always approved, preventing the domain verification agent from changing it.
    • adb devices -l
           
      
      10: treat domain as always denied, preventing the domain verification agent from changing it.
  • adb devices -l
    
    
    11: space-separated list of domains to change, or "all" to change every domain.

adb devices -l

12

Manually set the state of a host user selection for a package. The domain must be declared by the package for this to work. This command will not report a failure for domains that could not be applied.

  • adb kill-server 25: the user to change selections for
  • adb devices -l
    
    
    05: the package to set
  • adb devices -l
    
    
    15: whether to approve the domain
  • adb devices -l
    
    
    11: space-separated list of domains to change, or "all" to change every domain

adb devices -l

12

Manually set the state of a host user selection for a package. The domain must be declared by the package for this to work. This command will not report a failure for domains that could not be applied.

  • adb kill-server 25: the user to change selections for
  • adb devices -l
    
    
    05: the package to set
  • adb devices -l
    
    
    15: whether to approve the domain
  • adb devices -l
    
    
    11: space-separated list of domains to change, or "all" to change every domain

adb devices -l

22

Toggle the auto-verified link-handling setting for a package.

  • adb kill-server 25: the user to change selections for
  • adb devices -l
    
    
    05: the package to set, or "all" to set all packages; packages will be reset if no package is specified
  • adb devices -l
    
    
    25: true to allow the package to open auto-verified links, false to disable

adb devices -l

26

Print the owners for a specific domain for a given user in low- to high-priority order.

  • adb kill-server 25: the user to query for
  • adb devices -l
    
    
    05: optionally also print for all web domains declared by a package, or "all" to print all packages
  • adb devices -l
    
    
    11: space-separated list of domains to query for

Call device policy manager (

adb devices -l

30)

To help you develop and test your device management apps, issue commands to the device policy manager (

adb devices -l

  1. tool. Use the tool to control the active admin app or change a policy's status data on the device.

While in a shell, the

adb devices -l

30syntax is:

$ adb devices List of devices attached device_ip_address:5555 device

4

You can also issue a device policy manager command directly from

adb kill-server

7 without entering a remote shell:

$ adb devices List of devices attached device_ip_address:5555 device

5

Table 3. Available device policy manager commands

Command Description

adb devices -l

34 Sets component as active admin.

Options are:

  • adb kill-server 25: Specify the target user. You can also pass adb devices -l
    
    
    36 to select the current user.

adb devices -l

37 Set component as active admin and its package as profile owner for an existing user.

Options are:

  • adb kill-server 25: Specify the target user. You can also pass adb devices -l
    
    
    36 to select the current user.
  • adb devices -l
    
    
    40: Specify the human-readable organization name.

adb devices -l

41 Set component as active admin and its package as device owner.

Options are:

  • adb kill-server 25: Specify the target user. You can also pass adb devices -l
    
    
    36 to select the current user.
  • adb devices -l
    
    
    40: Specify the human-readable organization name.

adb devices -l

45 Disable an active admin. The app must declare

adb devices -l

46 in the manifest. This command also removes device and profile owners.

Options are:

  • adb kill-server 25: Specify the target user. You can also pass adb devices -l
    
    
    36 to select the current user.

adb devices -l

49 Clear the device's record of previously set freeze periods for system OTA updates. This is useful to avoid the device scheduling restrictions when developing apps that manage freeze periods. See .

Supported on devices running Android 9.0 (API level 28) and higher.

adb devices -l

50 Force the system to make any existing network logs ready for retrieval by a DPC. If there are connection or DNS logs available, the DPC receives the

adb devices -l

51 callback. See .

This command is rate-limited. Supported on devices running Android 9.0 (API level 28) and higher.

adb devices -l

52 Force the system to make any existing security logs available to the DPC. If there are logs available, the DPC receives the

adb devices -l

53 callback. See .

This command is rate-limited. Supported on devices running Android 9.0 (API level 28) and higher.

Take a screenshot

The

adb devices -l

54 command is a shell utility for taking a screenshot of a device display.

While in a shell, the

adb devices -l

54 syntax is:

$ adb devices List of devices attached device_ip_address:5555 device

6

To use

adb devices -l

54 from the command line, enter the following:

$ adb devices List of devices attached device_ip_address:5555 device

7

Here's an example screenshot session, using the

adb kill-server

7 shell to capture the screenshot and the

adb connect device_ip_address:5555

30 command to download the file from the device:

$ adb devices List of devices attached device_ip_address:5555 device

8

Record a video

The

adb devices -l

59 command is a shell utility for recording the display of devices running Android 4.4 (API level 19) and higher. The utility records screen activity to an MPEG-4 file. You can use this file to create promotional or training videos or for debugging and testing.

In a shell, use the following syntax:

$ adb devices List of devices attached device_ip_address:5555 device

9

To use

adb devices -l

59 from the command line, enter the following:

adb kill-server

0

Stop the screen recording by pressing Control+C. Otherwise, the recording stops automatically at three minutes or the time limit set by

adb devices -l

61.

To begin recording your device screen, run the

adb devices -l

59 command to record the video. Then, run the

adb connect device_ip_address:5555

30 command to download the video from the device to the host computer. Here's an example recording session:

adb kill-server

1

The

adb devices -l

59 utility can record at any supported resolution and bit rate you request, while retaining the aspect ratio of the device display. The utility records at the native display resolution and orientation by default, with a maximum length of three minutes.

Limitations of the

adb devices -l

59 utility:

  • Audio is not recorded with the video file.
  • Video recording is not available for devices running Wear OS.
  • Some devices might not be able to record at their native display resolution. If you encounter problems with screen recording, try using a lower screen resolution.
  • Rotation of the screen during recording is not supported. If the screen does rotate during recording, some of the screen is cut off in the recording.

Table 4.

adb devices -l

59 options

Options Description

adb connect device_ip_address:5555

54 Display command syntax and options

adb devices -l

68 Set the video size:

adb devices -l

69. The default value is the device's native display resolution (if supported), 1280x720 if not. For best results, use a size supported by your device's Advanced Video Coding (AVC) encoder.

adb devices -l

70 Set the video bit rate for the video, in megabits per second. The default value is 20Mbps. You can increase the bit rate to improve video quality, but doing so results in larger movie files. The following example sets the recording bit rate to 6Mbps:

adb kill-server

2

adb devices -l

71 Set the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).

adb devices -l

72 Rotate the output 90 degrees. This feature is experimental.

adb devices -l

73 Display log information on the command-line screen. If you do not set this option, the utility does not display any information while running.

Read ART profiles for apps

Starting in Android 7.0 (API level 24), the Android Runtime (ART) collects execution profiles for installed apps, which are used to optimize app performance. Examine the collected profiles to understand which methods are executed frequently and which classes are used during app startup.

Note: It is only possible to retrieve the execution profile filename if you have root access to the file system, for example, on an emulator.

To produce a text form of the profile information, use the following command:

adb kill-server

3

To retrieve the file produced, use:

adb kill-server

4

Reset test devices

If you test your app across multiple test devices, it may be useful to reset your device between tests, for example, to remove user data and reset the test environment. You can perform a factory reset of a test device running Android 10 (API level 29) or higher using the

adb devices -l

74

adb kill-server

7 shell command, as shown:

adb kill-server

5

When restoring the device using

adb devices -l

74, the device automatically backs up the RSA key that allows debugging through the current workstation in a persistent location. That is, after the device is reset, the workstation can continue to debug and issue

adb kill-server

7 commands to the device without manually registering a new key.

Additionally, to help make it easier and more secure to keep testing your app, using the

adb devices -l

74 to restore a device also changes the following device settings:

  • The device sets up certain system settings so that initial device setup wizards do not appear. That is, the device enters a state from which you can quickly install, debug, and test your app.
  • Settings:
    • Disables lock screen.
    • Disables emergency alerts.
    • Disables auto-sync for accounts.
    • Disables automatic system updates.
  • Other:
    • Disables preinstalled security apps.

If your app needs to detect and adapt to the default settings of the

adb devices -l

74 command, use the .

sqlite

adb devices -l

81 starts the

adb devices -l

82 command-line program for examining SQLite databases. It includes commands such as

adb devices -l

83 to print the contents of a table and

adb devices -l

84 to print the

adb devices -l

85 statement for an existing table. You can also execute SQLite commands from the command line, as shown:

adb kill-server

6

Note: It is only possible to access a SQLite database if you have root access to the file system, for example, on an emulator.

For more information, see the

adb devices -l

81 command line documentation.

adb USB backends

The adb server can interact with the USB stack through two backends. It can either use the native backend of the OS (Windows, Linux, or macOS) or it can use the

adb devices -l

87 backend. Some features, such as

adb devices -l

88,

adb devices -l

89, and USB speed detection, are only available when using

adb devices -l

87 backend.

You can choose a backend by using the

adb devices -l

91 environment variable. If it isn't set, adb uses its default backend. The default behavior varies among OS. Starting with API level 34, the native backend is used by default. If

adb devices -l

91 is set, it determines whether the native backend or

adb devices -l

87 is used. See the adb manual page for more information about adb environment variables.

adb mDNS backends

ADB can use the multicast DNS protocol to automatically connect the server and devices. The ADB server ships with two backends, Bonjour (Apple's mdnsResponder) and Openscreen.

The Bonjour backend needs a daemon to be running on the host machine. On macOS Apple's built-in daemon is always running, but on Windows and Linux, the user must make sure the

adb devices -l

94 daemon is up and running. If the command

adb devices -l

95 returns an error, it is likely that ADB is using the Bonjour backend but there is no Bonjour daemon running.

The Openscreen backend does not need a daemon to be running on the machine. Support for the Openscreen backend on macOS starts at ADB v35. Windows and Linux are supported as of ADB v34.

By default ADB uses the Bonjour backend. This behavior can be changed using the environment variable

adb devices -l

96 (set to

adb kill-server

51 or

adb kill-server

50). See the ADB manual page for further details.