Ranorex Help Center How can we help you?

Testing of Android Wear Apps

Following the instructions below you can easily create automated tests on compatible Android Wear apps directly on real or emulated devices.

Prerequisites

  • Install adb:
    The Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android device.
    You can find it at <Ranorex Installation folder>\Bin\RxEnv\Android\tools.
  • Connect with the phone:
    Download the Android Wear app on your phone and pair the watch with your phone. You can find detailed information on how to do so here:  https://support.google.com/androidwear#topic=6056405
  • Enable the debug mode:
    On the smartphone go to "Developer Options" and enable "USB Debugging".
    On the watch got to "Developer Options" and enable "ADB Debugging" as well as "Debug over Bluetooth".
  • Finally, open the Android Wear app on your smartphone, press the Settings button on the top right and check the "Debugging over Bluetooth". The target should be shown as connected.

Note If the target is still disconnected, try to restart both the smartphone and the watch.

Getting Started

Connect the device via USB to your computer and call adb via command line by typing "adb devices".

It should print something like this:

List of devices attached
08937p69d0518aac device

This means you have successfully connected your phone to your computer. Now we need to connect the watch too. Type the following commands:

adb forward tcp:6666 localabstract:/adb-hub
adb connect localhost:6666


Note You need to accept the connection on your watch.

Type once again "adb devices". You should now see a new device called localhost:6666:

08937p69d0518aac device
localhost:6666 device

In your Android Wear App, Host and Target should now show up as connected.

Note Connecting host and target does not always work at first go. Try restarting both devices in different order and be patient.

Automate on an Emulated Device

The following instructions explain how to connect a Genymotion emulated smartphone with a Google emulated watch.

First, download Genymotion setup and start any Genymotion emulator with Android 4.3 or later. For Google's emulated watch you need the AVD Manager.

Start the Android Studio, go to Tools -> Android -> AVD Manager. Create a new Virtual Wear device and start it.

Next, install Google Apps or Gapps on the Genymotion smartphone. With Gapps, also the Play Store will be installed, which is needed for downloading the Wear App.

Go to http://wiki.cyanogenmod.org/w/Google_Apps and download the correct Gapps for your emulator. To install Gapps on Genymotion, please follow these instructions.

Note Gapps may sometimes be unstable when running on Genymotion emulators.

Follow the steps explained in Prerequisites and list your devices via adb as described in Getting Started.

It should print something like this:

List of devices attached
192.168.154.102:5555 device

This means you have successfully connected your emulated phone to your computer. Now you need to connect the watch too. Type the following command into the command line:

adb -s {genimotion_ip}:{genimotion_port} -d forward tcp:5601 tcp:5601

Type once again the "adb devices" command. You should see a new device called emulator-5600.

You can now add your devices, instrument and deploy your app and record and run your android tests.