Home » adb

Tag: adb

ADB commands - Adventures in QA

Powerful ADB commands for Android Tester

If you are working as mobile tester in an Android development team you are probably familiar with adb commands (Android Debug Bridge). The tool offers plenty of useful commands that help you to pull logs from the Android device or emulator. Besides pulling log files from the test device there are plenty of other useful commands that every mobile tester in an Android environment must know. Before using adb make sure the Android SDK is installed, a device is connected to your computer or an Android emulator has been started. Note: In order to use the adb commands on your test devices make sure that on every device the developer options and USB debugging are enabled.

Both options are hidden by default. On Android 4.2 and higher you can enable them by tapping seven times the build number in the Settings > About phone section. Once the developer options are enabled open them and enable USB debugging.

ADB commands

Start/ Stop ADB server

If a device is connected start the adb server to be able to interact with the device.

adb start-server

adb kill-server

List connected devices

adb devices
Will list all connected devices. Read more

Android Screen Recording using ADB

Android Screenrecord - Adventures in QAThanks to Richard Bradshaw, also known as the @FriendlyTester, who reminded me in a tweet about the Android screen recording feature using an ADB (Android Debug Bridge) command. In one of my last posts, I already wrote about the new QuickTime recording feature for iOS devices running iOS8 in combination with a Mac OS X device running Yosemite.

A couple of posts ago I wrote about an app called ilos that is able to record Android screens as well. However, I totally forgot to mention in that post that Android is already able to record the current screen using an ADB command.

The screenrecord command is able to record the display of devices running Android 4.4 (API level 19) and higher. The tool is recording the app interaction to an MPEG-4 file, which can be downloaded from the device using the command adb pull. This video can then be used as part of your bug report as well.

The following sample will start a recording session of the connected device.

$ adb shell screenrecord /sdcard/NotAbleToLogin.mp4

To stop the screen recording press Ctrl-C, otherwise the recording will stop automatically after three minutes. However, you can also define a time limit with the paramter --time-limit.

The tool is recording the video in the native display resolution and orientation by default. However, there are some limitations of the screenrecord command that you should know when using it:

  • Some Android devices are not able to record the session with their native screen resolution. If you see any kind of problems during the recording session, try to use a lower resolution.
  • The tool is not able to record screen orientation during the recording session. When you rotate the device during the session, some parts of the screen will be cut off.
  • There is no audio recording support.

The following table is showing the options of the screenrecord command. Note: This table is copied from the developer.android.com page.

--helpDisplays a usage summary.
--size <WIDTHxHEIGHT>Sets the video size, for example: 1280x720. The default value is the device’s main display resolution (if supported), 1280×720 if not. For best results, use a size supported by your device’s Advanced Video Coding (AVC) encoder.
--bit-rate <RATE>Sets the video bit rate for the video, in megabits per second. The default value is 4Mbps. You can increase the bit rate to improve video quality or lower it for smaller movie files. The following example sets the recording bit rate to 6Mbps:

screenrecord --bit-rate 6000000 /sdcard/demo.mp4
--time-limit <TIME>Sets the maximum recording time, in seconds. The default and maximum value is 180 (3 minutes).
--rotateRotates the output 90 degrees. This feature is experimental.
--verboseDisplays log information on command line screen. If you do not set this option, the utility does not display any information while running.


Richard Bradshaw send me a link to his GitHub Gists where he provided a shell script that is able to start, download and delete a recorded video from the Android device. Maybe this can be useful for you guys as well.

BASH script to record Android display and download/delete the video.

#Check if an argument was supplied
if [ -z "$1" ]
echo "No argument supplied, please provide video name"
# start recording
adb shell screenrecord –bit-rate 6000000 /sdcard/$1.mp4 &
# Get its PID
# Upon a key press
read -p "Press [Enter] to stop recording…"
# Kills the recording process
kill $PID
# Wait for 3 seconds for the device to compile the video
sleep 3
# Download the video
adb pull /sdcard/$1.mp4
# Delete the video from the device
adb shell rm /sdcard/$1.mp4
# Kill background process incase kill PID fails

Happy recording and testing!


Mobile App Update Testing

During the development process of mobile apps manual and automated testing is highly recommended. But there is another test you should do before releasing or submitting your app to a store. Testing the update procedure! Testing the update procedure from the current store version to the new release candidate is really important and it is often not done by developers or QA experts. With this test you verify, that the new app is not affecting the old installed version. Here are three facts that will be covered with that test.

Test that the update…

  • … will not logout a user from the app e.g. before the update he was logged in.
  • … will not affect the local database e.g. existing data will not be modified or deleted.
  • … will be installed correctly from the store (simulation).

You can also test the update from far older versions to the latest one, to see what is happening.
For the two big players Android and iPhone I will describe, how to test the update from one version to another using different tools.

On the iOS side there are two ways of testing the update procedure. The first one can be done with iTunes. See also the Technical Note TN2285 from Apple.

  1. Build an adhoc app version of the app that is currently live in iTunes store. HINT: This version must have the same bundle identifier as the new app.
  2. Be sure that no older versions of the app are installed within iTunes and on your test iOS device (Sync with iTunes to be sure).
  3. Drag the app from step 1 into iTunes and sync the version to your test device.
  4. Launch the app and do some manual testing to see that the app is working.
  5. Build the new release candidate version of the app and drag it to iTunes and sync to the device. iTunes should confirm, that the older version will be removed. HINT: DO NOT delete the old build! In the next step iTunes will install the new app over the old one and will simulate the update from the app store.
  6. Launch the new version and see if everything is ok.

The second way of testing the update procedure for iOS is using the iPhone Configuration Utility. Using this tool is more comfortable, especially if you want to test the update procedure on more iOS test devices like iPhone 3G, iPhone 3GS, iPhone 4(S), iPhone 5 or iPads.

  1. Build an adhoc app version of the app that is currently live in iTunes store. HINT: This version must have the same bundle identifier as the new app.
  2. Be sure that no older versions of the app are installed on the test device.
  3. Install the app from step 1 to the devices you want to check.
  4. Launch the app and do some manual testing to see that the app is working.
  5. Build the new release candidate version of the app and install it with the tool. The update procedure will be simulated.
  6. Launch the new version and see if everything is ok.

The same can be done also on the Android side. To test the update for Android you can use adb to simulate the procedure.

  1. Install the current Google Play store version of your app to your phone.
  2. Check that the version is working.
  3. Build a release candidate of the Android app. HINT: Be sure to sign the release candidate with the Play store keystore.
  4. Use the following command to test the update procedure:
    ./adb install -r APPNAME.apk. The option -r means reinstall the app and keeping its data.
  5. The new version is now installed and can be tested.

That’s it! Try it for your next release!