How to use ADB, the Android development debugging tool

How to use ADB, the Android development debugging tool

ADB (Android Debug Bridge) is a tool in the Android SDK. ADB can be used to directly operate and manage the Android emulator or a real Andriod device.

The main functions of ADB are:

1. Run Shell (command line) on Android device

2. Manage port mappings for simulators or devices

3. Upload/download files between computers and devices

4. Install the local APK software on the computer to the Android emulator or device

1. Before using ADB, first check whether the Android SDK toolkit has been installed in your Eclipse , as shown below:

This USB driver is also needed to connect your Android device.

ADB is a client-server program, where the client is the computer you use to operate it, and the server is the Android device.

2. If you have installed the Android SDK, you can find the directory ..\android-sdk-windows\platform-tools in your SDK directory . The ADB tool is located here. As shown in the figure:

Copy the path of this directory. We need to set this path to PATH in the system settings of Windows. After the setting is completed, we can use ADB in the CMD window.

3. We now start our andriod virtual machine and enter the CMD window.

The emulator-5554 here is my virtual machine device

4. Commonly used ADB commands

a) adb install <apk file path>

This command installs the specified apk file on the device

b) adb uninstall <software name>

adb uninstall -k <software name>

If you add the -k parameter, the software will be uninstalled but the configuration and cache files will be retained.

c) adb shell

This command will log in to the shell of the device

adb shell <command>

Adding <command> at the end will directly run the device command, which is equivalent to executing a remote command

d) adb help

This command will display help information.

c) adb push <local path> <remote path>

Send files from your computer to your device

adb remount Before executing the push command, we also need to use the remount command to obtain the upload file permission, otherwise

Read-only file system error message

The example is as follows

It should be noted that if you need to put a file in a secondary directory, you must use "/" instead of "\", because Android is a Linux system, and we use Windows. For example: sdcard/aa, otherwise it will prompt that it cannot be found or the permission is insufficient.

d) adb get-product

Get the device ID

e) adb get-serialno

Get the serial number of the device

f) adb devices

Get a list of currently running emulator/device instances and the status of each instance

g) adb bugreport

View bug report

5. Commonly used ADB Shell commands

Enter the shell through the adb shell command

a) Accessing the database

  1. sqlite3

b) Record wireless communication logs

Generally speaking, there are a lot of wireless communication logs, and it is not necessary to record them during operation, but we can still set the logs through commands:

  1. logcat -b radio

c) Delete the app

Android does not provide a command to uninstall the application, you need to delete it manually:

  1. cd /data/app

rm application name.apk

d) View the directory

  1. ls

e) Print or set the current system time

  1. date  

f) View memory information

  1. cat /proc/meminfo

g) Check CPU information

  1. cat /proc/cpuinfo

6. Delete the software that comes with the Android system Rom

a. Make sure your phone is rooted and you have root permissions to delete system files.

b. Download Android_db.rar and unzip it to %windir/%System32.

c. Connect the phone to the data cable, open cmd on the computer, and enter the command

  1. adb remount
  2. adb shell
  3. su

After the execution is complete, you will see:

* daemon not running. starting it now *

* daemon started successfully *

d. Then it is Linux command line mode, enter

  1. cd system/app

You will find that there is no change, then enter ls and press Enter.

At this time, the list shows all the files in system/app, which are some software integrated by Rom.

e. Start deleting! For example, if you want to delete Youtube, its file names are Youtube.odex and Youtube.apk

We want to delete these two files, type the following command:

  1. rm Youtube.*

Restart, Youtube has been deleted. Please note that students should not delete anything you don’t know what it is.

7. sqlite3 adb command

Two ways to access the database

*** type: sqlite3 database name.xx

The second method: adb shell

sqlite3

.databases

List database file names

.tables ?PATTERN?

List table names matching ?PATTERN?

.import FILE TABLE

Import data from a file into the file

.dump ?TABLE?

Generate SQL scripts to form database tables

.output stdout

Print output to the screen

.mode MODE ?TABLE?

Set data output mode (csv,html,tcl...

.nullvalue STRING

Replace the output NULL string with the specified string

.read FILENAME

Execute the SQL statements in the specified file

.schema ?TABLE?

Print the SQL statement for creating the database table

.separator STRING

Replace the field separator with the specified string

.show

Prints the settings of all SQLite environment variables

.quit

Exit the command line interface

<<:  Android Fragment uses full parsing

>>:  I've learned a lot. It turns out that Android screen adaptation can be played like this

Recommend

15 interesting facts about mobile apps

Editor's note: Himanshu Mehra is an online ma...

Wang Tong · Douyin SEO practical class, guide you step by step to do Douyin SEO

Wang Tong · Douyin SEO landing practice class, ha...

2022 Veterans’ Academic Advancement Policy: What are the benefits?

Every soldier contributes his own part to the cons...

Use this trick well and your user conversion rate will increase exponentially!

Let me tell you a story first: Smart little begga...

Earphones may make Apple the king of wearables

I ran down the subway station stairs, thinking I ...

How to do well in Baidu Q&A? How to do marketing promotion on Baidu Q&A?

There are many ways of online promotion, such as:...

As Tik Tok becomes Vlog, what opportunities are there for brand marketing?

This year, especially since the second half of th...

One picture reveals the secret code of new media copywriting

I don’t know when it started, but the mobile phon...

How much does it cost to customize a nutritional product mini program in Ganzi?

The main factors affecting the price of mini prog...