Most used Android Debug Bridge (adb) commands
Before you can start developing for Android, the Android SDK is required. One of the tools provided within the Android SDK is the Android Debug Bridge aka ADB.
With adb a debug connection is created with an Android device. This connection can be used for a various features: Getting information about all installed applications, collecting device logging, file management.. and many more. Keep reading to learn all about ADB.
Yes; Android Studio makes usages of adb on the background. adb is used for all communication with the Android Device.
More information about app bundles (.aab) can be found on the blog: Road to App Bundle and Bundletool
Thank you for reading this article, If you liked the article, help others find this article by sharing it.
With adb a debug connection is created with an Android device. This connection can be used for a various features: Getting information about all installed applications, collecting device logging, file management.. and many more. Keep reading to learn all about ADB.
Add adb.exe to default path enviroments
By default adb.exe is found within android_sdk/platform-tools/. In order to use the adb tool the cmd path must be the same. As it's used that often, most people add it to PATH system variable. xda-developers how to add adb.exe to PATH variableBasic commands
Before we can start using the adb commands, step 1 is to be able to start and stop the process service.- adb start-server
Command to launch the adb process service which handles all adb commands
- adb stop-server
Command to stop the adb process service
- adb shell
shell access to Android Unix file system
- adb devices
List all connected Android devices
Yes; Android Studio makes usages of adb on the background. adb is used for all communication with the Android Device.
- adb logcat
Prints all device logging from the Android device
File management commands
For developers the command line is easier to use than the old skool explorer, or when making scripts to automate process, adb supports file management. Two most often commands used are push and pull.- adb push <source> <destination>
Command to push one file from the host machine to Android device
adb push .\test-file /sdcard/
- adb pull <source>
Command to pull (download) one file from Android device to the host machine
adb pull /sdcard/test-file
Application commands (.apk, .aab)
Android applications have the extension .akp, where for Windows the applications have .exe as extension. Android Studio generates .apk applications and it's they are served by Google Play Store.More information about app bundles (.aab) can be found on the blog: Road to App Bundle and Bundletool
- adb install <apk-file>
Command to install an .apk file
adb install application.apk
- adb uninstall <package>
Command to remove an installed application
adb uninstall com.example.application
- adb shell pm list packages -f
Command to list all installed packages
Media commands
If you have access to ADB, the most easy way to created a screenshot is using ADB- adb shell screencap -p /mnt/sdcard/sreenshot.png
- adb pull /mnt/sdcard/sreenshot.png
With both commands the screenshot is taken and downloaded to the host machine
- adb shell screenrecord /sdcard/demo.mp4
- adb pull /sdcard/demo.mp4
With both commands a screenshot is taken downloaded to the host machine
Triggering Intents
When creating an app that reacts on intents of other apps or even system broadcasts it's always hard to trigger those. These days are over! With adb these intents can be triggered, just from the command line.- adb shell am broadcast -a <android-intent>
- adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
With this command a fake incoming broadcast is triggered
- adb shell am start -a android.intent.action.CALL -d tel:1234567
With this command a fake incoming call is triggered
Other commands
Last but not least there are several commands which can't be placed inside a category, but are quite usefull- adb shell monkey -p <package> -v --throttle <speed> <amount>
- adb shell monkey -p com.example.application -v --throttle 250 500
- adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
The monkey commands does exactly what it says; it behaves like a monkey and will trigger every possible button and input feature there is within Android.
Links
With this guide of ADB commands you've learned how to use to most common ADB commands. If you are missing some ADB commands, we like to hear it in the comments!Thank you for reading this article, If you liked the article, help others find this article by sharing it.
BeantwoordenVerwijderenThis post is so interactive and informative.keep updating more information...
Android Training in Mumbai
Android Development Course in Kolkata