Android Command Line Tools

This section provides a list of commonly used Android command line tools that can be executed on the Bourne shell.

The Android system also provided its own programs that you can run on the Bourne shell command line. Here are some examples:

adb (Android Debug Bridge) - "adb" is a command line tool that normally provided on an external system to perform remote access to Android systems. But it is also provided on Android systems that you ran it locally.

"adb" allows you to run shell commands on the target device, copy files from and to the target device, installing application packages to the target device, etc.

Here is an example session of running "adb shell" on my Android emulator:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell
   (Running "adb shell" on my Windows system)
   
# adb shell
   (Running "adb shell" on my Android emulator)

adb shell
* daemon not running. starting it now on port 5038 *
* daemon started successfully *
# exit
exit
#

am (Activity Manager) - "am" is a command line tool that allows you to manage activities like: starting an application activity, stop activities, monitor activities, etc.

Here is an example session of running "am start" to start my "AndroidWeb" application:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell

# am start com.herongyang.web/.AndroidWeb
am start com.herongyang.web/.AndroidWeb
Starting: Intent { act=android.intent.action.MAIN cat=
   [android.intent.category.LAUNCHER] 
   cmp=com.herongyang.web/.AndroidWeb }

dalvikvm (Dalvik VM) - "dalvikvm" is a command line tool that allows you to launch the Dalvik VM run a Java class in DEX format.

Here is an example session of running "dalvikvm -version" on my Android emulator:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell

# dalvikvm -showversion
dalvikvm -showversion
ART version 2.1.0

logcat - "logcat" is a command line tool that allows you to dump log entries from 3 log buffers: main, events and radio.

Here is an example session of running "logcat" on my Android emulator:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell

# logcat *:E
logcat *:E
--------- beginning of system
--------- beginning of crash
E/AndroidRuntime( 1819): FATAL EXCEPTION: main
E/AndroidRuntime( 1819): Process: com.herongyang.debug, PID: 1819
E/AndroidRuntime( 1819): java.lang.RuntimeException: Unable to start 
activity ComponentInfo{com.herongyang.debug/com.herongyang.debug.
AndroidDebug}: java.lang.IllegalStateException: The specified child 
already has a parent. You must call removeView() on the child's parent
first.
,,,
^C

monkey - "monkey" is a command line tool that allows you to perform a monkey testing on an application.

Here is an example session of running "monkey" to perform a monkey test on my "AndroidWeb" application:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell

# monkey -p com.herongyang.web 500
monkey -p com.herongyang.web 500
    // Injection Failed
    // activityResuming(com.android.documentsui)
    // Injection Failed
    // activityResuming(com.android.documentsui)
    // Injection Failed
Events injected: 500
## Network stats: elapsed time=31980ms (0ms mobile, 0ms wifi, 31980ms 
not connected)

pm (package manager) - "pm" is a command line tool that allows you to manage application packages.

Here is an example session of running "pm" to list features and packages:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell

# pm list features
pm list features
feature:reqGlEsVersion=0x0
feature:android.hardware.audio.output
feature:android.hardware.bluetooth
feature:android.hardware.camera
feature:android.hardware.camera.any
feature:android.hardware.camera.autofocus
...

# pm list packages
pm list packages
package:com.android.smoketest
package:com.example.android.livecubes
package:com.android.providers.telephony
package:com.herongyang.web
package:com.android.providers.calendar
package:com.android.providers.media
package:com.android.protips
package:com.android.launcher
package:com.android.documentsui
package:com.android.gallery
package:com.android.externalstorage
package:com.android.htmlviewer
package:com.android.quicksearchbox
package:com.android.mms.service
package:com.android.providers.downloads
package:net.sf.andpdf.pdfviewer
package:com.android.browser
...

More tutorial examples on using these command line tools are provided in other sections.

Last update: 2015.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows System

 Installation of Android SDK R24 and Emulator

 Installing Apache Ant 1.9 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 Android 4.0.3 File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

 Building Your Own Web Browser

Android Command Line Shell

 What Is the Bourne Shell?

 Bourne Shell Command Line Examples

 Unix/Linux Command Line Programs

Android Command Line Tools

 "dalvikvm" Command to Run Java Application

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Outdated Tutorials

 References

 PDF Printing Version