Packaging and installing Android Wear Watchface

208 Views Asked by At

I've read several other questions regarding this same topic however I am still at my wit's end trying to figure out how to get my Watchface to appear on my Android Wear device, let alone publish it to the Play Store.

The project has a mobile app which houses a blank activity and then the Wear app (Watchface) which houses the activity for the Watchface. I've attempted the following

  • signing both Wear and mobile apks and installing then both on my phone (mobile app shows with blank activity but no Wear Watchface available on watch)

  • installing the signed Wear apk separately (also does not display as a selectable Watchface)

  • running the Wear Watchface in the Android Studio emulator (works)

  • making sure that the same permissions exist in both mobile and Wear manifests

  • ensuring that all project IDs match up and are the same

Any advice or help would be great.

2

There are 2 best solutions below

0
On BEST ANSWER

After much digging, I was able to get to the solution.

In order for a watch face or a wear apk to be moved on the watch for debugging purposes, one must ensure the following

  1. Ensure all of these items are met in addition to the following.
  2. Turn on debugging in both the Android Wear application as well as on the watch itself. (Debugging on the watch can be turned on by enabling developer options by tapping the build number) You would want to enable debugging over bluetooth
  3. Your phone should also be plugged into to a computer that has adb and enable adb debugging on the device itself.
  4. Typing adb-devices in Command Prompt will list all of the devices found
  5. Connect the debugger to the watch by adb forward tcp:4444 localabstract:/adb-hub adb connect 127.0.0.1:4444
  6. Ensure that both target and Host are connected by opening the Android Wear companion app, tap settings and viewing the status message that appears under the bluetooth debugging toggle option. It should read Host: connected Target: connected
  7. adb-devices should now show both the phone and the watch. From here on you can use adb commands to push the wear apk to the watch.

Source

0
On

Writing watch face to wear 1.x.x or 2.0 involves extending your Java class to The CanvasWatchFaceService class and registering your watch face in the manifest and also working with the CanvasWatchFaceService.Engine class.

You don't have to create an Activity you will have to create a view and inflate or mostly draw the view in “void onDraw(Canvas canvas, Rect bounds)”. You have to register the service in your manifest like as shown below.

    <meta-data
    android:name="com.google.android.wearable.watchface.preview"
    android:resource="@drawable/preview_face" />

   <meta-data
    android:name=
    "com.google.android.wearable.watchface.preview_circular"
     android:resource="@drawable/preview_face_circular" />

Also You have to have Wake lock permission

 <uses-permission android:name="android.permission.WAKE_LOCK" />

we need to add a special intent filter with the goal that watch.

 <intent-filter>
 <action android:name="android.service.wallpaper.WallpaperService" />

 <category
     android:name=
     "com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>

It will be usual signed android apk to publish within playstore no much of difference.

Also there are plenty of resources that will get you started like medium blogs and reddit blogs and so on. Check this book for more information on Wear : Android wear Projects