1.) Setup on Linux (Ubuntu)
sudo apt-get update sudo apt-get install -y android-tools-adb android-tools-fastboot
1b.) Setup on Windows
I recommend the Minimal ADB and fastboot Package by shimp208, which you can get from: https://forum.xda-developers.com/showthread.php?t=2317790.
After you've installed it, you should add the folder of the installation to your PATH Variable: Press WIN+X Key, choose System, Advanced Systemsettings, Advanced, Path Variables - or just press WIN+R and enter "C:\Windows\system32\rundll32.exe" sysdm.cpl,EditEnvironmentVariables
- you will need to click on the entry Path in the User Variables, edit and then create a new entry by clicking on new. There, you'll need to enter the path to Minimal ADB and Fastboot, i.e. C:\Program Files (x86)\Minimal ADB and Fastboot
, click ok and close everything. Now you can use adb and fastboot from CMD in every folder.
2) Using it!
ADB can be used to do almost anything with Android Devices - as long as Android Debugging is activated. Developer Mode is activated via Settings -> Status and clicking 7 times on "Build number". After that, the Developer Options are available in the Settingsmenu. In this menu, you need to activate Android Debugging and connect your Phone via USB to your PC. You can start i.e. the Android Shell by accessing your Terminal and starting adb shell
In the Android Shell, you can navigate the file system of your phone or change different settings, i.e. you can change the brightness of your screen via:
settings put system screen_brightness 200
There are a lot of settings you can change, some are listed here:
Settings System: https://developer.android.com/reference/android/provider/Settings.System.html
Settings Global: https://developer.android.com/reference/android/provider/Settings.Global.html
Settings Secure: https://developer.android.com/reference/android/provider/Settings.Secure.html
You can also get a list of your current settings with settings list [namespace], i.e.
settings list system
You can also reboot your phone if it is rooted, move files, edit them, delete them - everything you can do on a normal linux system.
Another useful adb commands are pull and push. With adb pull
you can pull a file from your phone to your pc. And with adb push
you can upload a file to your phone.
Also, you can adb install
install apk files / apps or adb uninstall
uninstall them.
Important for debugging is the access to the logcat daemon via adb logcat
so you can see what happens on your phone. You can even filter for different apps, i.e. chromium: adb logcat -s chromium
There is a bunch of other goodies like forwarding socket connections or reverse sockets and backup / restore of apps - which you can find out by looking at the useful adb help
output.
Fastboot is the last command I want to describe here. You can use adb to reboot your phone to bootloader (adb reboot bootloader
) or recovery (adb reboot recovery
). If your phone is rooted and you get it into the bootloader, you can access it via fastboot. This tool is vital to flashing new kernels, images, recoverys and other stuff if everything else fails. Knowing that it exists should be enough for the "normal status of operation" - but if something breaks - use it ;)!