Android Wear app not installing through handset

Solution 1:

To Answer @odiggity specifically, in build.gradle file of your phone app, you should mention the exact name of the wear app folder. If you created the project in Android Studio, then your build.gradle should look like this:

                      wearApp project(':wear')

This can happen because of the following reasons:

  • Wear & Mobile app's "permissions" are not same (Wear App permissions should be a subset of Mobile App permissions).

This is not documented anywhere on developers website, however I found this with my personal experience. The reason I can think of behind this restriction is, Google want to prevent sneaky developers to exploit users & their privacy.

  • Package name of Wear & Mobile apps are not matching.
  • VersionNumber & VersionName of both Wear & Mobile app not matching
  • Application ID (build.gradle file) of Mobile & wear app are not matching.
  • by default wearable packages are only included in release builds
  • both apps must be signed with the same key
  • as of Android Studio 3.0 apk builds created with run are test only builds that don't allow installation on wear (returnCode -15, see this information)
  • Asset Compression

If you are using Eclipse for development, make sure you turn off the "Asset Compression" otherwise the ".apk" file in raw folder will get double compressed & the phone won't be able to recognize if the Mobile app is packaging wear app or not.

Best Solution:

Use Android Studio.

  1. Create Android Project
  2. Select Phone & Wear project
  3. Follow the steps for project creation
  4. Copy all the permissions used in Wear app to Mobile app's Manifest or vice versa

Debugging

When you don't find the wear app on the wearable you can always look into logs of both devices to see what is going on. You can filter on WearablePkgInstaller to find all logging related to wearable package installation.

From the Wear OS app on you device trigger the "resync apps" option from "advanced settings" and check the logs. Alternative way to sync only the wearable for your app is to reinstall your app. At that point the wearable is also synced for your package.

Device logging should list something like:

11-07 14:58:53.127 3330-8739/? I/WearablePkgInstaller: Setting DataItem to install wearable apps for com.spotify.music

With com.spotify.music being your app Id. This is just an example for Spotify.

And on the watch (debug over bluetooth or USB) you can find logging with this same filter showing issues or success:

11-07 15:00:02.533 1032-1048/? I/WearablePkgInstaller: Package com.spotify.music was installed.

Most error messages are self explanatory. You can find many examples of these errors in the source code of WearPackageInstallerService class. Some however are just a returnCode. For these return codes check the values in this PackageManager source code.

Solution 2:

I had ussue with wear product flavors. I had flavors in both handheld and wear apps. To solve my issue I used next code in build.gradle handheld app file:

freeWearApp project(path: ':wear', configuration: 'wearfreeRelease')
fullWearApp project(path: ':wear', configuration: 'wearfullRelease')

where, free and full are flavors from handheld module, wearfree and wearfull are flavors from wear mudule, Release is name of wear module buildtype.

And don't forget publishNonDefault true in the android block of the wear gradle.

Solution 3:

I had this problem even after checking the package names, application IDs, and making sure the wear module didn't have any permissions that the handheld module didn't.

My problem was that I was requesting the permission android.permission.BIND_NOTIFICATION_LISTENER_SERVICE in AndroidManifest.xml for the wearable module. It seems that this should only be requested for the handheld module.