For a lot of us, the fact that we can plug our Android phone into a computer and interact with it is a big plus. Besides the times when we've broken something and need to fix it, there are plenty of reasons why an advanced Android user would want to talk to their device. To do that, you need to have a few tools and know a few commands. That's what we're going to talk about today.
Granted, this won't be the end-all be-all discussion of adb commands, but there are 10 basic commands every android app developer should know if they plan to get down and dirty with the command line.
You'll need some tools and getting them is easy. Head on over to the Android developer's site. You can either install the full Android Studio package if you want extra debugging tools or you can scroll down to the bottom of the page and download just the command line tools. Unless you're developing or debugging something on or for your phone, you'll want just the command line tools.
If you're using Windows, there's one more step. Visit the manufacturer's page for your device and install the adb and fastboot drivers for Windows. You'll need this so that your computer can talk to your Android device. If you hit a snag (Windows can be fickle) visit the forums and somebody is bound to be able to help you through it.
Now that we're all on the same page, enable USB debugging on your device (see your devices manual if you need help finding it) and plug your phone into your computer.
Here we go.
1. The adb devices command
The adb devices command is the most important one of the bunch, since it's used to make sure your computer and Android device are communicating. That's why we're covering it first.
2. The adb push command
If you want to move a file onto your Android device programmatically, you want to use the adb push command. You'll need to know a few parameters, namely the full path of the file you're pushing, and the full path to where you want to put it. In the picture above I'm pushing a song from my Music folder on my desktop to the music folder on my phone.
3. The adb pull command
If adb push sends files to your Android device, it stands to reason the adb pull command would pull them out.
4. The adb reboot command
This is exactly what you think it is — a way to reboot your device from the command line. Running it is simple: just type adb reboot and enter.
5. The adb reboot-bootloader and adb reboot recovery commands
Not only can you reboot your device, you can specify that it reboots to the bootloader. This is awfully handy, as sometimes those button combos are touchy, and if you have a lot of devices it's tough to remember them all. Some devices don't even have a way to boot to the bootloader without this command. And once again, being able to use this command in a script is priceless.
Doing it is easy, just type adb reboot-bootloader and hit the enter key.
6. The fastboot devices command
When you're working inside the bootloader, adb no longer works. You're not yet booted into Android, and the debugging tools aren't active to communicate with. You'll need to use the fastboot command in its place.
7. The fastboot unlock command
The holy grail of Android commands, fastboot flashing unlock does one thing, and one thing only -- unlocks your bootloader. It's not enabled on every phone, even phones that support fastboot, but we're including it because even if you don't need it, it's an important part of Android's openness.
8. The adb install command
While adb push can copy files to our Android devices, adb install can actually install apps. You'll need to supply the path where you have the .apk file saved, then run it like this: adb install TheAppName.apk.
9. The adb sideload command
An OTS (over-the-air) update is downloaded by your phone as a .zip file. You can also download that zip file manually and install it without having to wait for your phone to have the update pushed to it. The end result is the same as if you had waited, but we hate waiting.
10. The adb shell command
The adb shell command confuses a lot of folks. There are two ways to use it, one where you send a command to the device to run in its own command line shell, and one where you actually enter the device's command shell from your terminal.