Skip to content

Instantly share code, notes, and snippets.

@Fahime-zv
Last active November 3, 2021 02:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Fahime-zv/a9c020b903dc525015af7917f56bd1a4 to your computer and use it in GitHub Desktop.
Save Fahime-zv/a9c020b903dc525015af7917f56bd1a4 to your computer and use it in GitHub Desktop.
==> Install app
adb install Myapp.apk
adb -d install Myapp.apk //-d (directs command to the connected USB device.)
adb -e install Myapp.apk //-e (directs command to the running emulator.)
adb -s install Myapp.apk //-s<serial number>
adb -p install Myapp.apk //-p <product name or path>
----------------------------------------------------------------------------------------------------------
==> Uninstall app
adb uninstall com.package.myapp
adb uninstall -k com.facebook.katana //-k Keep the data and cache directories around after package removal.
----------------------------------------------------------------------------------------------------------
==> Logcat
adb logcat //displays the log data onto the screen
adb logcat -c //you can clear the existing logs on an Android device.
adb logcat -d > [path_to_file] //you can save the logcat output to a file on your computer.
----------------------------------------------------------------------------------------------------------
==> Reboot device
adb reboot //ADB can be used to reboot your device, useful when your hardware buttons aren’t working.
adb reboot bootloader //Reboots the device into the Fastboot or Bootloader mode.
adb reboot recovery //Reboots the device into recovery mode.
----------------------------------------------------------------------------------------------------------
==> Bugreport
adb bugreport //Displays the Android device information such as dumpsys, dumpstate and logcat data on the screen.
adb jdwp //Lists the JDWP (Java Debug Wire Protocol) processes on the device. if you’re not already aware of it, chances are you don’t have to worry about it either.
----------------------------------------------------------------------------------------------------------
==> Server
adb start-server //Starts the adb server process.
adb kill-server //Stops the adb server process (terminal adb.exe process).
----------------------------------------------------------------------------------------------------------
==> Files
adb pull /sdcard/screenrecord.mp4 //This command can be used to pull any files from your device and save it on your computer. To download or pull a file from your Android device to the SDK platform-tools directory, use
adb pull /sdcard/screenrecord.mp4 e:\ //If you want to download a file from your phone’s storage to a specific drive on your computer, execute the this command
adb push Myapp.apk /sdcard //This command can be used to push a file from your computer to your device. If the file to be pushed it save in the SDK folder, use
adb push e:\Myapp.apk /sdcard // To push or send a file to your Android from a specific drive on your computer, use
----------------------------------------------------------------------------------------------------------
==> Permissions
adb shell pm reset-permissions -p com.package.myapp // Reset App's permission
adb shell pm grant [packageName] [Permission] // Grant a permission to an app
adb shell pm revoke [packageName] [Permission] // Revoke a permission from an app
----------------------------------------------------------------------------------------------------------
==> Package info
adb shell list packages // list package names
adb shell list packages -r // list package name + path to apks
adb shell list packages -3 // list third party package names
adb shell list packages -s // list only system packages
adb shell list packages -u // list package names + uninstalled
adb shell dumpsys package packages // list info on all apps
adb shell dump <name> // list info on one package
adb shell path <package> // path to the apk file
----------------------------------------------------------------------------------------------------------
==> Print text
adb shell input text 'Hello world'
----------------------------------------------------------------------------------------------------------
==> Screenshot
adb shell screencap -p /sdcard/screenshot.png
----------------------------------------------------------------------------------------------------------
==> Monkey
adb shell monkey -p com.myAppPackage -v 10000 -s 100 // Monkey is generating 10.000 random events on the device
----------------------------------------------------------------------------------------------------------
==> Other
adb backup // Create a full backup of phone and save to the computer
adb restore // Restore a backup to phone
adb sideload // Push and flash custom ROMs
----------------------------------------------------------------------------------------------------------
@majid-khosravi
Copy link

majid-khosravi commented Apr 6, 2021

==> Connection Managment

adb tcpip 5555 // Set the target device to listen for a TCP/IP connection on port 5555
adb connect 192.168.1.20:5555 // Connect to the device by its IP address
adb disconnect // Disconnect the USB cable from the target device.
adb devices // You can generate a list of attached devices

@Fahime-zv
Copy link
Author

Thank you very much. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment