54

I don't have an Android Wear, nor do I have a phone running 4.3. Is there a way to connect the JB 4.3 emulator and Android Wear emulator for app development?

Gurupad Mamadapur
  • 989
  • 1
  • 13
  • 24
user2498079
  • 2,872
  • 8
  • 32
  • 60

9 Answers9

152

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 attached
emulator-5554   device
emulator-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 commands
OK

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)

reVerse
  • 35,075
  • 22
  • 89
  • 84
  • Works like a charm. Make sure and set the redirection on the phone, not the watch of course. – Heath N Jun 16 '15 at 07:12
  • 1
    Nice trick, however I found that I could not send messages to the wear emulator using the wearable data layer API. The same code worked fine using a real phone. – Brad Pitcher Jun 23 '15 at 23:37
  • Why is `5601` used? I can't get it to work with this port, my current ports are 5554 (phone) and 5556 (watch). – Afzaal Ahmad Zeeshan Sep 20 '15 at 08:43
  • 5601 ist the port that Android Wear uses to communicate with the handheld device. The ports of the phone / watch don't matter in this case. The command / port is taken directly from the [official docs (link)](https://developer.android.com/training/wearables/apps/creating.html). – reVerse Sep 20 '15 at 08:55
  • 1
    I got this error `'telnet' is not recognized as an internal or external command, operable program or batch file. ` – Ketan Ahir Oct 26 '15 at 12:05
  • @KetanAhir See this [StackOverflow-Post](http://stackoverflow.com/questions/25031090/telnet-is-not-recognized-as-internal-or-external-command) – reVerse Oct 26 '15 at 12:22
  • Thanks for this post! But I have question, is here any way how to go around that `telnet` thing? Something like use `shell` inside emulated phone? I have to do this on school computer and without admin rights and without telnet – Sk1X1 Feb 22 '16 at 15:29
  • @Sk1X1 I'm not aware of an alternate way that the telnet one - sorry – reVerse Feb 22 '16 at 15:32
  • @reVerse too bad, but really thanks for this! I will try to resolve this with IT guys at school. – Sk1X1 Feb 22 '16 at 15:38
  • 5
    on mac the command "redir add tcp:5601:5601" fails with message "KO: unknown command, try 'help'" – noev Jul 29 '16 at 08:51
  • 7
    Finally, something that works. One extra step I had to complete was to enter an auth token, but the terminal instructions were clear enough: `Android Console: Authentication required Android Console: type 'auth ' to authenticate Android Console: you can find your in '/home//.emulator_console_auth_token'` – PPartisan Oct 12 '16 at 11:09
  • I tool almost two days fixing this and finally this thread helped me. One things I want to mention is the Authentication that needs to follow after the telnet command. For example (if your key is oAquOnwIe+eOeBq/ ): auth oAquOnwIe+eOeBq/ Once you are authenticated, you can follow on running the redir command – Mahesh N Nov 24 '16 at 00:06
  • 2
    This no longer works. Tried both API 22 and 25 emulators to wear API 23, it says "Emulator: connecting..." – Yaroslav Mytkalyk Dec 01 '16 at 13:29
  • Hi @noev I have the same problem... I'm wondering if you found any solution. Thanks. – Fabio B. Jan 21 '17 at 16:10
  • 1
    The Wear companion app crashes while trying to access bluetooth. I'm using the latest wear app on the latest emulator. – Devesh Khandelwal Jan 30 '17 at 09:34
  • 5
    This is no longer working for API 25 with apk version 2.0.0.153114386. The android wear app stops running. – Alex Apr 18 '17 at 20:39
  • I had to jump through many hoops but this is working for me using version 2.0.0.163484626.gms of the Wear app, API 25 of Wear OS and API 26 of Mobile OS. – Kris B Aug 08 '17 at 19:19
  • Use adb instead of telnet: `adb -s forward tcp:5601 tcp:5601` – Jason Sep 23 '17 at 22:27
  • 1
    This has stopped working for me. Hopefully Google makes it easier to pair a phone emulator to a watch emulator because it's a PITA right now. – Kris B Apr 22 '18 at 20:07
9

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 attached
emulator-5554   device
emulator-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

Manish Menaria
  • 23,899
  • 3
  • 21
  • 23
4

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!

Anthony De Smet
  • 2,265
  • 3
  • 17
  • 24
  • This worked for me. The key was booting the phone emulator first, running the tcp command then booting the watch emulator. – Kris B Mar 29 '21 at 19:43
2

Tried all solutions described above in the following environments:

  • Mac OS High Sierra
  • Android API 26, 27 (on both Wear and Phone)
  • Android Studio 3.0.1 and then 3.1.2
  • Wear OS apps com.google.android.wearable.app-2.apk and *-3.apk

Spent the whole day to test all the combinations, but was not able to pass "Emulator Connecting" stage

enter image description here

Then started reading official Android docs:

https://developer.android.com/training/wearables/apps/creating#setting-up-a-phone

It says explicitly that connecting Wear AVD to Phone AVD is not possible, which is consistent with my experience. Probably it worked for older versions, I don't know.

enter image description here

Oleg Gryb
  • 5,122
  • 1
  • 28
  • 40
1

@Sk1X1 I would comment but unfortunately don't have enough reputation points.

Try using:

adb -s xxxxx forward tcp:5601 tcp:5601

where 'xxxxx' is the device specific name which you get by running the command adb devices. As an example with reference to @reVerse's answer: emulator-5556

Note: I haven't tested this myself.

1

This can now be done using Android Studios' Wear OS emulator pairing assistant: https://developer.android.com/training/wearables/get-started/creating#pairing-assistant

Note: Your phone must run Android 11 (API level 30) or higher and have the Google Play Store installed to use the Wear OS emulator pairing assistant. Also, make sure your Wear emulators run API level 28 or higher to use the latest assistant features. To upgrade system images for your emulated devices, use the SDK Manager.

CrazyJ36
  • 599
  • 4
  • 4
0

One more step after Step#6 in the above post is Authentication after Telnet and before redir command

Authentication that needs to follow after the telnet command. For example (if your key is oAquOnwIe+eOeBq/ ): auth oAquOnwIe+eOeBq/ Once you are authenticated, you can follow on running the redir command .

If this is not done, you get the error "Android Console: Authentication required Android Console: type 'auth ' to authenticate Android Console: you can find your in '/home//.emulator_console_auth_token'

Mahesh N
  • 772
  • 1
  • 10
  • 21
0

This thread is quite old an the anwser of reVerse is already quite helpful. But since Android Studio has changed some UI elements over the time, here is an update.

1. Step you must create the right handheld/smartphone device, one that contains the Google Play Service. Create device: Create device

The correct device you can recognize by the Google Play symbol : Create device including google play services In the following steps, make sure you use an Android OS 11 or higher

2. Step create a wear os device (if you don't have it yet). This works the same way: Create device

Right now all wear os devices include the Play Store, but make sure yours includes it too, since the list might change over time: enter image description here Follow the istructions and your wear os is set up too

3.Step now your device manager should have at least the two devices you created. Click at the three vertical dots of your wear os device. A context menu opens and you can click on "Pair Wearable": enter image description here

After this, you just have to select the handheld device with the google playstore service: enter image description here

4. Step You just have to follow the instructions, both your emultated devices will be started automatically. The steps require you to sign in with your google account on the handheld emulator and confirming a few things. Afterwards you should be good to go.

user2267367
  • 704
  • 7
  • 19
-2

Using an emulated Android 4.3 device connected to a Wear emulator is not supported at this time.

Wayne Piekarski
  • 3,203
  • 18
  • 19