In late February 2019, I had just finished my military service. I was staying temporarily at a relative’s house in Istanbul and was looking for a job; it was a tough time. I was constantly attending interviews, trying to fit in 2–3 interviews per day with HR or technical positions.

Image generated by ChatGPT

In late February 2019, I had just finished my military service. I was staying temporarily at a relative’s house in Istanbul and was looking for a job; it was a tough time. I was constantly attending interviews, trying to fit in 2–3 interviews per day with HR or technical positions. ADB is one of the questions.

Peak Games had just aired a famous commercial on all TV channels at the same time. You probably remember it; it was talked about a lot. In March, I had an interview with Peak, a company I really wanted to work for. The position was not related to game development; it was for an “Android Developer” role. They were planning to work on a different project, but it was confidential, so I can’t share details.

For the evaluation project they gave me, I used Kotlin, RxJava, Data Binding, LiveData, and Navigation. I chose a Modular MVVM structure. I successfully passed this stage with a nice project, and they invited me to the office for a live coding session. Unfortunately, I failed the interview. At that time, I didn’t even know idiomatic Kotlin, and I wasn’t at the level they required.

However, I received the most valuable feedback of my career, which helped me improve significantly. I’ve interviewed with many large e-commerce platforms, but I never learned as much as I did from this experience. One of the key pieces of feedback I got was about ADB.

They mentioned in their email, “We expected an Android developer to know ADB.” At first, I thought, “Why would I need ADB when Android Studio is so good?” But after they asked about it in such an important interview, I learned what it was, and later, it became a tool I used frequently. You will be surprised to see how versatile ADB is.



What is ADB?

ADB is a command-line tool that allows you to run commands on Android devices. It enables developers to interact with Android devices or emulators and is used for various development and debugging tasks. You can connect your Android device to your computer via USB or over the network to execute commands on the device.



Main Uses of ADB:

1. Device Connection and Management:

Check if a device is connected and its status.
Example command: adb devices lists connected Android devices.

2. App Installation and Testing:

Install APK files directly onto an Android device and run them.
Example command: adb install myapp.apk installs the APK file.

3. Debugging:

Get logcat output from the device to watch for app errors and system messages.
Example command: adb logcat shows logs from the device.

4. File Transfer:

Transfer files between your computer and the Android device.
Example command: adb push local_file /sdcard/ transfers a file from your computer to the Android device.

5. Command-Line Device Management:

Run shell commands on the device. This allows you to execute commands directly on the device.
Example command: adb shell gives you access to the device's command line.

6. Running and Stopping Apps:

Start or stop installed apps, change system settings, and more.
Example command: adb shell am start -n com.example/.MainActivity starts a specific app.



How to Use ADB?

Android mascot connected via USB cable with Android Debug Bridge text displayed.

Image created by Tom



How to Setup ADB:

You don’t need to install Android Studio to use ADB. It comes with Android SDK Platform Tools, which you can download separately from the Android Developer website.



Enabling Developer Mode and USB Debugging:

To use ADB with a real Android device, you need to enable USB debugging in the developer options on the device. Don’t worry, your phone and data will be safe. Here’s how to do it:

  • Go to Settings > About Phone on your Android device.

  • Tap on Build Number 7 times to enable developer mode.

  • Then, go to Settings > Developer Options and enable USB Debugging.



Using ADB Commands:

ADB is run from the terminal or command line. Let’s try running the command that lists connected Android devices:

typescript
adb devices


General Use Cases of ADB:

  • App Development and Testing: Developers use ADB to test apps on real devices and view app logs. Personally, I used it in this scenario the most: After generating the APK file with gradlew clean and gradlew assembleRelease, I would navigate to the path android\app\release using the cd command, find the APK, and uninstall the app from my device. Then, I would use the adb install command to install the APK and do a final test on my personal device before submitting it to the Google Play Store.

  • System Modification: ADB allows users to make customizations to Android systems or access deeper parts of the device. For instance, developers can change the default animation speeds on Android devices. This is useful when developers want to see how the device performs faster during tests by lowering or disabling animation speeds. With the following commands, all animations on the device can be disabled, making the transitions in the user interface faster. This modification lets you see the device’s real speed, independent of animations. Here are the commands:

csharp
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
  • Root Operations: On rooted devices, ADB can be used to access system files and perform various operations. I’ve never used ADB for root operations as I don’t prefer rooting devices, but I’m curious about it.



ADB Commands I Used:

So, where did my ADB knowledge come in handy? While working at ING Turkey, performance and memory were our top priorities when we were building a banking app from scratch. We used ADB to monitor performance, as Android Profiler was still very new back then. Here are some of the commands we used:

1. Monitoring CPU Usage:

To track CPU usage in real-time, use this command:

css
adb shell top

This command shows you the current CPU usage and which apps are consuming CPU resources.

2. Monitoring GPU Usage:

You can enable the GPU visual indicator in Android to track graphic performance. This feature shows frame rates and delays for specific apps and visualizes GPU usage.

xml
adb shell dumpsys gfxinfo <uygulama_paketi_adı> framestats

3. Memory Usage:

To check memory usage for running apps, use this command:

typescript
adb shell dumpsys meminfo

This command shows memory usage for all apps on the device. You can also specify an app package to see memory usage for just that app.

4. Battery Performance:

To see the device’s battery status and usage, use this command:

typescript
adb shell dumpsys battery

This shows information like battery level, temperature, voltage, and charging status.

5. Network Performance:

To monitor network data usage and performance, use these commands:

typescript
adb shell dumpsys netstats

This gives you information about the device’s network data usage, both for Wi-Fi and mobile data.

6. Profiling Commands (Systrace):

For more detailed performance analysis, you can use the Systrace tool. This tool tracks CPU, GPU, I/O, memory, and more. Run it with this command:

lua
adb shell atrace --categories gfx,view,wm,am,sm --buffer-size=100000 --duration=10

This command captures a 10-second trace and gives you the results. For deeper performance analysis, Systrace is very effective in optimizing Android performance.

ADB was a tool I initially overlooked, but it ended up being an invaluable resource in my Android development journey. The feedback I received from my interview with Peak Games played a major role in improving both my technical knowledge and problem-solving skills. After learning ADB, I was able to test my apps more effectively and perform deeper operations on devices. If you’re an Android developer, I highly recommend learning ADB; it’s a skill that will take your work to the next level!