InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Android development tutorials

  • Android - Show top processes using adb
  • Android studio keyboard shortcuts
  • Disable sleep during android usb debugging
  • Download apk using AirDroid
  • Enable usb debugging
  • Exerciser monkey tutorial
  • Find top processes by memory/cpu on Android using Adb
  • Find used ports by an app on Android using Adb
  • Install Android 8 on Pixel 2
  • Root Android pixel 2 using Magisk and boot image patching
  • Transfer android apk using adb
  • Using Google analytics SDK v2 for android app real time tracking
  • View Desktop Site
  • adb tutorial
 
  • Home
  • > Tutorials
  • > Android Development

adb – android debug bridge – quick tutorial

By admin on Sep 24, 2015

adb (android debug bridge) is a command line tool which lets you communicate with your usb connected android devices or android emulators. Here are some handy commands to use adb. We used mac for the purpose of this tutorial. Note that you must enable USB debugging on your android phone for adb to work.

List devices

To list all devices connected to your machine and emulators running on your machine:

$ adb devices
List of devices attached
013884750301A00A	device
emulator-5554	device

Get shell on device

To run a shell on device connected to usb run the following

$ adb -d shell

To run a shell on only emulator run the following

$ adb -e shell

In there there are two or more emulators, you can specify the specific one using -s

$ adb -s emulator-5554 shell

Install apk using adb

To install an apk file on connected device, run the following

$ adb -d install -r app.apk

start an app on connected device

Activity can be started using shell and am (activity manager)

$ adb -d shell am start -a android.intent.action.MAIN -n com.foo.myapp/.MainActivity

Stop an activity

To stop an activity run the following

// com.foo.myapp is package name
$ adb -d shell am force-stop com.foo.myapp

view android log

To view logs on connected device

$ adb -d logcat
// or 
$ adb -d logcat -f out.txt

Note that using -d or -e option is pretty handy way to connect to connected device of emulator if only one device is connected or only one emulator is running. Otherwise you will have to first print device id and then connect to that device.

Suggested posts:

  1. curl – some handy commands
  2. Linux – number of cpus (lscpu)
  3. Android – install android 8, 9 from OTA images on pixel 2
  4. How to download apk from mobile using AirDroid
  5. Install Android 8 on Pixel 2
  6. Root Android pixel 2 using Magisk and boot image patching
  7. Git – how to undo last commit
  8. Find top processes by memory/cpu on Android using Adb
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Android Development, Linux/Unix Command Line, Mac, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress