I\'m trying to get a wearable app installed through an Android handset using the \'Package with Android Studio method\' found here but it\'s not working. The apk is never in
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.
From my experience it only works when building a signed release build. When deploying a debug build it never installed the wear app for me. With signed release it worked with buildToolsVersion "19.1.0".
In this specific case I can see that you are using "compile project(':GooglePlay')". Is that the latest version? (compile 'com.google.android.gms:play-services-wearable:+')
Got the same problem, it turned out that newrelic is instrumenting the Android Wear App. Try to comment the line: // apply plugin: 'newrelic'
I couldn't find a way to tell newrelic to keep away from the the wear app...
as far as I know product flavors are not supported at the moment, either use the manual build (asset or raw) or remove the product flavors.
Just wanted to add something that I haven't seen in many answers.
You have to match the applicationId
in your handheld app and wear app.
I previously thought that you needed to have <uses-feature android:name="android.hardware.type.watch" />
in both the handheld and watch manifest, with add: android:required="true"
for the wearable manifest and android:required="false"
for the device.
THIS IS FALSE. You do not need the above in the handheld manifest. In fact with Wear 2.0 coming up Google has made some changes that will not allow you to upload any apk with minSdk lower than 23 if <uses-feature android:name="android.hardware.type.watch" />
is in your handheld app. Sorry for any confusion.
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:
"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 matchingApplication ID
(build.gradle file) of Mobile & wear app are not matching.release
buildssigned
with the same keytest only builds
that don't allow installation on wear (returnCode -15, see this information)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.
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.