Nowadays, there are a huge number of different gaming platforms: PCs, consoles, mobile devices, and others. In this article, we will talk about a tool for the most popular mobile gaming platform – Android. Android Debug Bridge (ADB for short) is a utility that is available from the Android SDK through the command line.
Android Debug Bridge as irreplaceable tool in game testing
Android Debug Bridge as irreplaceable tool in game testing
- Posted by: Admin
Android SDK (Android Software Development Kit) is an application development environment for the Android operating system. It allows creating and testing Android applications.
ADB (Android Debug Bridge) is a console application for a PC used to debug Android devices, including emulators. It works on the client-server principle. The first time ADB is launched with any command, a server is created in the form of a system service (daemon) that will listen to all commands sent to port 5037.
Daemon is an ADB component that works as a background process for each emulator or device instance. It receives commands from the ADB server and executes them.
Installing ADB. Setting up the environment and device
ADB is a part of the Android SDK Platform-Tools, which, in turn, is a component of the Android SDK and includes various tools for interacting with the Android platform. Therefore, after installing Android Studio, one can use the SDK Manager and download the latest version of the tool. You can also download the Android SDK Platform Tools separately here.
After installing ADB/SDK you need to open the «Edit the system environment variables» window.
Click on the «Environment Variables» button in the «Advanced» tab of the properties window.
The list of environment variables will include one named «Path». Select it and click the «Edit» button or double-click on the row.
The «Edit System Variable» window will be opened, where it is necessary to add the path to the «Tools» and «Platform-Tools» folders. It is important to put the «;» sign after the last variable in the field.
After all the settings, you need to restart the computer. To check if the changes have been applied, you need to write the command «adb devices» in the command line. If the information appears as in the screenshot below, it means that everything has been done correctly and the settings have been applied.
To work in ADB with a mobile device, you also need to make changes to the device itself. The configuration of any particular device differs depending on the manufacturer, model, and software version installed on it. But, in general, all the steps can be more or less summarized as the following:
- Go to the Settings – About section.
- Tap on the build number 7 times.
- Open the «Developer options» section in the settings.
- Activate the «USB debugging» item.
How to use ADB in testing
Even though ADB functions can be used by ordinary users, this utility is most often used in testing applications and games on mobile devices. There are a lot of features, but below you can see the main ones that will be helpful to testers in their work:
- view of the list of devices connected to the PC and their readiness to work with ADB;
- installation and uninstallation of applications on the device;
- view of the device logs;
- file transfer to the device from a PC and vice versa;
- clearing the data section;
- overwriting the data section;
- generating bug reports;
- managing access rights to the device, and so on.
One can see that the ADB's functionality is very large and, although it is a simple Android SDK utility, it is a must-have for testers on mobile devices. Below are the commands to implement the main functions.
While the ADB setup process may seem rather complicated for a beginner developer, and the command line interface is hardly user-friendly, once you successfully complete the ADB setup, you will get a whole set of highly useful commands. Let's take a look at a few of them below:
- adb start-server – starts the service/daemon;
- adb kill-server – the opposite of the first command, used to stop the service/daemon;
- adb devices – displays a list of all connected devices (including emulators), with their serial number and status;
- adb bugreport d:/12/ – is designed to create a zip archive with full debug information (dumpsys, dumpstate and logcat) in text format (.txt);
- adb logcat – probably the most popular and important of the ADB commands in game testing, it allows collecting and viewing logs from the device (logs can be written to a separate file or viewed directly in the Windows command line window);
- adb shell screencap /sdcard/name.png – this command allows you to take a screenshot of the device screen. It is important to note that after the command you have to specify the path, name, and extension of the future screenshot file (for example, /sdcard/screencap.png);
- adb shell screenrecord /sdcard/name.mp4 – allows recording video from the device screen without using third-party applications. Sometimes it is better to see a defect once than to describe it 100 times. Similarly to the screenshot command, you need to specify the path, name, and extension of the future video file after the command (for example, /sdcard/name.mp4);
- adb install C:cat.apk – as the command name suggests, it is designed to install packages (applications). To download an application from a PC, you have to specify the path, name, and extension of the .apk file (for example, C:cat.apk) after the command;
- adb push d:12textfile.txt /sdcard/ – a command to copy files from a PC to a mobile device;
- adb pull /sdcard/textfile.txt d:12 – to copy files from the device to a PC.
Options (keys) to commands
You can add keys to almost every ADB command that slightly change the performed function.
Let's look at a few commands with options:
- adb logcat > d:12logsname.txt – writing logs to the logsname.txt file in the d:12 directory ( the system will create a file with this name in case it doesn't exist);
- adb logcat – s Unity > d:12logsname.txt – writing Unity-filtered logs to the logsname.txt file in the d:12 directory;
- adb shell screenrecord --time – limit 30 /sdcard/name.mp4 – setting the video length limit to 30 seconds (the default limit is 180 seconds);
- adb install – s d:cat.apk – installation of the application on the SD card.
You can find a full list of commands and options on the website.
Android Debug Bridge is a useful and irreplaceable console application for testers on mobile devices. It has a lot of commands that can help you interact with devices using various functions.
The installation may seem a bit complicated, but afterward, you will appreciate the usefulness of this application in your work with devices.