Some primary uses of ADB

The full name of ADB is Android Debug Bridge, which is to play the role of debugging bridge.
Because a friend took a fancy to a game and wanted to extract the updated resources, but he couldn't find the folder location of the game in the phone. So let me take a look.
In conclusion, the location of the folder has been found, and the contents of this folder have been exported, but the location of the update file is still unclear. . . Perhaps the update was merged directly into the folder? And just simply replace resources? This needs to be studied later.


Tools used:

  1. jadx-1.3.3: This is mainly to unpack and look at the package name
  2. mumu emulator: Install apk, because the emulator defaults to root.
  3. Android Studio: Mainly to use adb (although you can also use the computer's cmd to start adb directly, but I'm still used to using it through Android Studio)
  4. apktool: for unpacking apk resources

1. The first thought is to test the game in the mobile phone and find the installation directory. Generally, the update path of the game is in /Android/data, such as Azur Lane, fgo, etc., but this game cannot be found. . . So you need to find out its specific installation path.

adb shell pm path 包名(com.xxx.xxx)

Using this command, you can query the installation path of the corresponding package name in the connected Android device.
At the beginning, I installed it on my mobile phone and checked it, and I did find it, but I encountered a problem when exporting it, that is, I need to root the phone, and the real phone must be rooted to use the root command of adb, and I My mobile phone is Black Shark. After checking the information, the rooting of this mobile phone seems to be quite troublesome, so I didn’t do it.

2. After thinking about it, I thought that I could try to use a simulator to do it, and the result was really feasible. The mumu emulator is used.

adb connect 127.0.0.1:7555

Using the above command, you can let adb connect to the mumu emulator. After that, the same method was used to find the installation path, which was the same as that in the real machine.
Some commands are also used here:

// 进入 adb
adb shell

// 进入指定路径
// 如果使用 cd / 则是返回最外层路径
cd /data/app

// 查看当前路径下的详细信息
ls -l

3. Then it is exported

// 这里前面的 /xx/xx/xx 是安卓系统中的要导出的文件的路径信息
// 后面的 F:\xx 是要导出到电脑中的位置,可以自己改
adb pull /xx/xx/xx F:\xx

The following are other adb related uses

1. View connected devices:

adb devices

2. Output the logcat log to the specified file ( refer to the article )

// 首先执行清空命令,将之前的 logcat 日志信息清空
adb logcat -c
// 将 logcat 信息打印到指定位置的文件中,该位置需要是绝对路径
adb logcat > D:/logcat.txt
// 打印结束后使用 Ctrl + C 退出

If you need to output the log of a specific Tag, you need to follow the
"-s" option as follows: Only display the log of the specified tag

// 其中 "Tag" 替换成要显示的 Tag 内容,引号是必须要带的
adb logcat -s "Tag" > D:/logcat.txt
// 例如,想输出 Tag = BannerTag 的日志
adb logcat -s "BannerTag" > D:/logcat.txt
// 想同时输出多个 Tag,只需要将相应的 Tag 使用引号加入即可
adb logcat -s "BannerTag" "RewardTag" > D:/logcat.txt

The above log output methods can only output specific Taglogs, but sometimes it is necessary to output logs with a certain keyword. At this time, the above methods cannot be used.

adb logcat | findstr "TAG" > D:/logcat.txt

The above command can output all TAGthe logs with content tags, such as: BannerTAG, RewardTAGetc. without quotation marks.
It should be noted that: it is used in the windows system , and needs to be replaced with findstrin the linux system . findstrgrep
PS: At the same time, it should be noted that it is best to use this command in cmd. In Android Studio, the information may not be output due to configuration or other reasons.

3. Use adb to install apk

adb -s (设备编号) install (apk 的绝对路径)

Among them, the device number is adb devicesobtained using .
It should be noted that the absolute path of the apk cannot contain it 空格. For example, if a folder named Apk Filescannot be found is displayed during the installation process Files, the folder should be named ApkFilesor Apk_Files.

C:\Users\Administrator>adb devices
List of devices attached
TPAKDXR1U7      device

In the above code TPAKDXR1U7is the device number of the device. Assuming that an application called Test.apk in the root directory of the D disk needs to be installed on the device, the code is as follows:

adb -s TPAKDXR1U7 install D:\Test.apk

Guess you like

Origin blog.csdn.net/EverNess010/article/details/126059518