Android Debug Bridge (Adb) - Android Studio - Android Developers
Android Debug Bridge (Adb) - Android Studio - Android Developers
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 command.
A server, which manages communication between the client and the daemon. The
server runs as a background process on your development machine.
adb is included in the Android SDK Platform Tools package. Download this package with
the SDK Manager (/studio/intro/update#sdk-manager), which installs it at
android_sdk/platform-tools/ . If you want the standalone Android SDK Platform Tools
package, download it here (/studio/releases/platform-tools).
For information on connecting a device for use over adb , including how to use the
Connection Assistant to troubleshoot common problems, see Run apps on a hardware
device (/studio/run/device).
Note: All adb clients use port 5037 to communicate with the adb 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 daemon (adbd), it sets up a connection
to that port.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 1/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Each emulator uses a pair of sequential ports — an even-numbered port for console
connections and an odd-numbered port for adb connections. For example:
As shown, the emulator connected to adb 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 commands to
access those devices. Because the server manages connections to devices and handles
commands from multiple adb clients, you can control any device from any client or from a
script.
You can now connect your device with USB. You can verify that your device is connected
by executing adb devices from the android_sdk/platform-tools/ 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 (/studio/run/device).
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 2/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Note: The instructions below do not apply to Wear devices running Android 11 (API level 30). See the
guide to debugging a Wear OS app (/training/wearables/get-started/debugging#wifi-debugging) 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.
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
(https://support.google.com/android/answer/7680439).
If using the IDE, ensure that you have the latest version of Android Studio installed.
You can download it here (/studio).
On your workstation, update to the latest version of the SDK Platform Tools
(/studio/releases/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:
2. Open Android Studio and select Pair Devices Using Wi-Fi from the run
configurations menu.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 3/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
The Pair devices over Wi-Fi window pops up, as shown in figure 2.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 4/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
a. 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.
b. 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
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 5/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
appears on the Pair devices over Wi-Fi window, you can select Pair and
enter the six-digit code shown on your device.
4. After your device is paired, you can attempt to deploy your app to your device.
5. If you want to quickly turn on and off wireless debugging, you can utilize the Quick
settings developer tiles (/studio/debug/dev-options#general) for Wireless debugging,
found in Developer Options > Quick settings developer tiles.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 6/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Figure 5. The Quick settings developer tiles setting lets you quickly turn wireless
debugging on and off.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 7/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
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 pair ipaddr:port . Use the IP address and
port number from above.
Figure 6. A message indicates that your device has been successfully paired.
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
connect ip:port over tcp/ip (following an initial USB connection) is another option,
in case resorting to a non-corp network is an option.
adb 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.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 8/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
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 debugging a Wear OS app
(/training/wearables/get-started/debugging#wifi-debugging) for more information.
adb usually communicates with the device over USB, but you can also use adb 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 host computer to a common Wi-Fi network.
star 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.
3. Set the target device to listen for a TCP/IP connection on port 5555:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 9/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
5. 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.
$ adb devices
List of devices attached
device_ip_address:5555 device
Make sure that your host is still connected to the same Wi-Fi network as your
Android device.
adb kill-server
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 10/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
adb devices -l
Serial number: adb creates a string to uniquely identify the device by its port
number. Here's an example serial number: emulator-5554
State: The connection state of the device can be one of the following:
device : The device is connected to the adb server. Note that this state does
not imply that the Android system is fully booted and operational, because the
device connects to adb while the system is still booting. After boot-up, this is
the normal operational state of a device.
Description: If you include the -l option, the devices 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 devices 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_f
emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_
0a388e93 device usb:1-1 product:razor model:Nexus_7 device:flo
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 11/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
You use the emulator command with the -port or -ports 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 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 server before you
use the emulator command, as explained in the following examples.
Example 1: In the following command sequence, the adb devices command starts the
adb server, but the list of devices does not appear.
Stop the adb 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
emulator -list-avds . The emulator command is in the android_sdk/tools directory.
$ adb kill-server
$ emulator -avd Nexus_6_API_25 -port 5555
$ adb devices
Example 2: In the following command sequence, adb devices displays the list of devices
because the adb server was started first.
To see the emulator in the adb devices output, stop the adb server, and then start it
again after using the emulator command and before using the adb devices command,
as follows:
$ adb kill-server
$ emulator -avd Nexus_6_API_25 -port 5557
$ adb start-server
$ adb devices
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 12/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
For more information about emulator command-line options, see Command-Line startup
options (/studio/run/emulator-commandline#startup-options).
1. Use the devices command to get the serial number of the target.
2. Once you have the serial number, use the -s option with the adb commands to
specify the serial number.
a. If you're going to issue a lot of adb commands, you can set the
$ANDROID_SERIAL environment variable to contain the serial number instead.
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 helloWorld.apk 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 displays an error "adb: more than one device/emulator".
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 13/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
If you have multiple devices available but only one is an emulator, use the -e option to
send commands to the emulator. If there are multiple devices but only one hardware
device attached, use the -d option to send commands to the hardware device.
Install an app
You can use adb to install an APK on an emulator or connected device with the install
command:
You must use the -t option with the install command when you install a test APK. For
more information, see -t (#-t-option).
To install multiple APKs use install-multiple . 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 (/studio/run).
Note: If you are using Android Studio, you do not need to use adb directly to install your app on the
emulator or device. Instead, Android Studio handles the packaging and installation of the app for you.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 14/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
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.
To copy a file or directory and its sub-directories from the device, do the following:
To copy a file or directory and its sub-directories to the device, do the following:
Replace local and remote with the paths to the target files/directory on your
development machine (local) and on the device (remote). For example:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 15/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
In some cases, you might need to terminate the adb server process and then restart it to
resolve the problem. For example, this could be the case if adb does not respond to a
command.
To stop the adb server, use the adb kill-server command. You can then restart the
server by issuing any other adb 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 -d , -e , or -s option to specify the target device to
which the command should be directed.
You can see a detailed list of all supported adb commands using the following command:
adb --help
To start an interactive shell on a device, use the shell command like this:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 16/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Android provides most of the usual Unix command-line tools. For a list of available tools,
use the following command:
Help is available for most of the commands via the --help argument. Many of the shell
commands are provided by toybox (http://landley.net/toybox/). General help applicable to all
toybox commands is available via toybox --help .
With Android Platform Tools 23 and higher, adb handles arguments the same way that the
ssh(1) command does. This change has fixed a lot of problems with command injection
(https://en.wikipedia.org/wiki/Code_injection#Shell_injection) and makes it possible to safely
execute commands that contain shell metacharacters
(https://en.wikipedia.org/wiki/Metacharacter), such as adb install Let\'sGo.apk . This
change means that the interpretation of any command that contains shell
metacharacters has also changed.
For example, adb shell setprop key 'value' is now an error, because the single
quotes ( ' ) are swallowed by the local shell, and the device sees adb shell setprop key
value . To make the command work, quote twice, once for the local shell and once for the
remote shell, as you do with ssh(1) . For example, adb shell setprop key 'value' .
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 17/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
am command
You can also issue an activity manager command directly from adb without entering a
remote shell. For example:
Command Description
Options are:
-S: Force stop the target app before starting the activity.
--opengl-trace: Enable tracing of OpenGL functions.
--user user_id | current: Specify which user to
run as; if not specified, then run as the current user.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 18/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Options are:
kill [options] package Kill all processes associated with package. This command
kills only processes that are safe to kill and that will not
impact the user experience.
Options are:
Options are:
Options are:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 19/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
profile start process file Start profiler on process, write results to file.
dumpheap [options] process file Dump the heap of process, write to file.
Options are:
Options are:
clear-debug-app Clear the package previous set for debugging with set-
debug-app.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 20/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
display-size [reset | Override device display size. This command is helpful for
widthxheight] testing your app across different screen sizes by mimicking
a small screen resolution using a device with a large screen,
and vice versa.
Example:
am display-size 1280x800
display-density dpi 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:
am display-density 480
Show all
-a action
-d data_uri
-t mime_type
Specify the intent MIME type, such as image/png . You can declare this only once.
-c category
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 21/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
-n component
Specify the component name with package name prefix to create an explicit intent,
such as com.example.app/.ExampleActivity .
-f flags
--esn extra_key
Add a null extra. This option is not supported for URI intents.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 22/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
--grant-read-uri-permission
--grant-write-uri-permission
--debug-log-resolution
--exclude-stopped-packages
--include-stopped-packages
--activity-brought-to-front
--activity-clear-top
--activity-clear-when-task-reset
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 23/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
--activity-exclude-from-recents
--activity-launched-from-history
--activity-multiple-task
--activity-no-animation
--activity-no-history
--activity-no-user-action
--activity-previous-is-top
--activity-reorder-to-front
--activity-reset-task-if-needed
--activity-single-top
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 24/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
--activity-clear-task
--activity-task-on-home
--receiver-registered-only
--receiver-replace-pending
--selector
Requires the use of -d and -t options to set the intent data and type.
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.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 25/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
pm command
You can also issue a package manager command directly from adb without entering a
remote shell. For example:
Command Description
list packages [options] filter Print all packages, optionally only those
whose package name contains the text in
filter.
Options:
list permissions [options] group Print all known permissions, optionally only
those in group.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 26/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Options:
Options:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 27/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
-i installer_package_name:
Specify the installer package name.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 28/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 29/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
get-app-links [options] [package] Print the domain verification state for the
given package, or for all packages if none is
specified. State codes are defined as
follows:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 30/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
system_configured: automatically
approved by the device config
Options are:
reset-app-links [options] [package] Reset domain verification state for the given
package, or for all packages if none is
specified.
Options are:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 31/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
set-app-links [--package package] state Manually set the state of a domain for a
domains 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.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 32/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
get-app-link-owners --user user_id [-- Print the owners for a specific domain for a
package package] domains given user in low- to high-priority order.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 33/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
dpm command
You can also issue a device policy manager command directly from adb without entering
a remote shell:
Command Description
Options are:
set-profile-owner [options] component Set component as active admin and its package as
Options are:
set-device-owner [options] component Set component as active admin and its package as
Options are:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 34/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
remove-active-admin [options] componentDisable an active admin. The app must declare and
command also removes device and profile owners.
Options are:
Take a screenshot
The screencap command is a shell utility for taking a screenshot of a device display.
screencap filename
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 35/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Here's an example screenshot session, using the adb shell to capture the screenshot and
the pull command to download the file from the device:
$ adb shell
shell@ $ screencap /sdcard/screen.png
shell@ $ exit
$ adb pull /sdcard/screen.png
Record a video
The screenrecord 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.
Stop the screen recording by pressing Control+C. Otherwise, the recording stops
automatically at three minutes or the time limit set by --time-limit .
To begin recording your device screen, run the screenrecord command to record the
video. Then, run the pull command to download the video from the device to the host
computer. Here's an example recording session:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 36/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
$ adb shell
shell@ $ screenrecord --verbose /sdcard/demo.mp4
(press Control + C to stop)
shell@ $ exit
$ adb pull /sdcard/demo.mp4
The screenrecord 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.
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.
Options Description
--size widthxheightSet the video size: 1280x720. 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.
--bit-rate rate 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:
screenrecord --bit-rate 6000000 /sdcard/demo.mp4
--time-limit time Set the maximum recording time, in seconds. The default and maximum
value is 180 (3 minutes).
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 37/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
--verbose Display log information on the command-line screen. If you do not set this
option, the utility does not display any information while running.
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:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 38/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
When restoring the device using testharness , 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
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
testharness 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:
Other:
If your app needs to detect and adapt to the default settings of the testharness
command, use the ActivityManager.isRunningInUserTestHarness()
(/reference/android/app/ActivityManager#isRunningInUserTestHarness()).
sqlite
sqlite3 starts the sqlite command-line program for examining SQLite databases. It
includes commands such as .dump to print the contents of a table and .schema to print
the SQL CREATE statement for an existing table. You can also execute SQLite commands
from the command line, as shown:
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 39/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
Note: It is only possible to access a SQLite database if you have root access to the file system, for
example, on an emulator.
You can choose a backend by using the ADB_LIBUSB environment variable. If it isn't set,
adb uses its default backend. The default behavior varies among OS. Starting with ADB
v34 (https://developer.android.com/tools/releases/platform-tools#revisions), the liubusb backend
is used by default on all OS except Windows, where the native backend is used by
default. If ADB_LIBUSB is set, it determines whether the native backend or libusb is
used. See the adb manual page
(https://android.googlesource.com/platform/packages/modules/adb/+/refs/heads/master/docs/user/ad
b.1.md)
for more information about adb environment variables.
Experimental: Support for using the libusb backend with Windows is experimental. As of ADB v34,
only the macOS and Linux platforms have been tested with the libusb library.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 40/41
04-08-2024, 01:17 Android Debug Bridge (adb) | Android Studio | Android Developers
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 mdnsd daemon is up and running. If the command adb mdns check 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_MDNS_OPENSCREEN (set to 1 or 0 ). See the ADB manual page
(https://android.googlesource.com/platform/packages/modules/adb/+/refs/heads/master/docs/user/ad
b.1.md)
for further details.
Content and code samples on this page are subject to the licenses described in the Content License
(/license). Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://developer.android.com/tools/adb#:~:text=If the adb connection to,the adb connect step again. 41/41