Pairing Android and Wear emulators Pairing Android and Wear emulators android android

Pairing Android and Wear emulators


After reading a blog post a few days ago I finally managed to connect an emulated Android-Device to a Wear-Emulator.
Here are the different steps that are necessary:

Step #1

Create a new emulator that is based on the Google APIs platform, otherwise you won't be able to run the Android Wear Companion app since it requires the Google Play Services. (See Android Developer site)

Emulator with Google APIs

Step #2

Start the Phone Emulator and install the Android Wear Companion app via the following command

adb install name_of_the_file.apk

You can download the latest apk from here.

Step #3

Start the Wear-Emulator.

Step #4

Open the Android Wear App on the Phone Emulator. Accept the TOS and so on.

Step #5

Open your command prompt and make sure both emulators are recognized with the following command

adb devices

Output should be something like this:

List of devices attachedemulator-5554   deviceemulator-5556   device

In my case emulator-5556 is the Phone. You can find this by looking at the Window-Title of the emulator.
See the following Screenshot:

Emulator window title

Step 6

Open your command prompt once again and start a telnet session on the port of your smartphone emulator:

telnet localhost 5556

Afterwards it'll try to connect and if it succeeds it'll show a new window saying something like this:

Android Console: type 'help' for a list of commandsOK

Now enter the following command:

redir add tcp:5601:5601

Afterwards it should say OK.

Step 7

Open the Android-Wear companion app once again and click on the watch-icon in the ActionBar and if everything worked it should connect to your Wear-Emulator.

Result image

And, as previously said, this was posted on kennethmascarenhas blog. (props to him)


for me, this command worked

adb -s emulator-5556 -d forward tcp:5601 tcp:5601

here are steps to be followed

Open your command prompt and make sure both emulators are recognized with the following command

ADB devices

Output should be something like this:

List of devices attachedemulator-5554   deviceemulator-5556   device 

if emulator-5556 is your phone emulator than just run this command

adb -s emulator-5556 -d forward tcp:5601 tcp:5601

[Note]

before all this you need to install com.google.android.wearable.app.apk into your phone emulator

  • first download apk from this link Apk file link
  • then go to the directory where you downloaded apk file and run this command

    adb -s emulator-5556 install com.google.android.wearable.app.apk

here com.google.android.wearable.app will be the downloaded apk name


I had a lot of trouble setting this up, but it worked with the following setup.

My specs

macOS Sierra 10.12.4, Android Studio 2.3.2

Emulator specs

Phone emulator: Nexus 5 API 25 -- Android 7.1.1 (Google APIs)Wear emulator: Android Wear Square API 25 -- Android 7.1.1 (Android Wear)

Instructions

  • After creating the proper emulators (and before starting them), download the Android Wear app APK file from http://www.file-upload.net/download-9437648/com.google.android.wearable.app-2.apk.html.
  • Start the phone emulator, wait for it to boot
  • Install the Wear app by using adb: adb -s emulator-5556 install /path/to/download/location/com.google.android.wearable.app-2.apk. Note that 5556 is where my emulator is running, yours might run on a different port. Check the emulator's title window
  • Connect to the device via telnet: telnet localhost 5556. It will complain about credentials, copy the code from the suggested file in the error and in the telnet connection window, execute auth <code>.
  • Still in the telnet window, run redir add tcp:5601:5601
  • Now run the Wear emulator, wait for it to boot
  • Open the Wear app on your phone. I had it crash the first time I tied, just try again. It will tell you bluetooth is unavailable and ask to pair to an emulator.

That's it, hope it works for you all because it all seems a bit fragile. Happy coding!