page.title=App Distribution meta.keywords="wear-preview" page.tags="wear-preview" page.image=images/cards/card-n-sdk_2x.png @jd:body
With Android Wear 2.0, a user can visit the Play Store on a watch and download a Wear app directly to the watch.
Generally, a Wear 2.0 app in the Play Store needs a minimum and target API level of 24 or higher in the Android manifest file. The minimum SDK level can be 23 only if you are using the same APK for Wear 1.0 and 2.0 (and thus have an embedded Wear 1.0 APK).
To make your app appear in the on-watch Play Store, upload the watch APK in the Play Developer Console just as you would any other APK. If you only have a watch APK and no phone APK, no other steps are required.
If you have a phone APK in addition to a watch APK, you must use the Multi-APK delivery method.
Run-time permissions are required.
Also see Standalone Apps.
If you only want your app to be distributed to Wear 2.0 watches, it is unnecessary to embed the watch APK inside the the phone APK.
If you want your app to be distributed to Wear 1.0 watches, you need to embed the watch APK inside the phone APK, as described directly below.
If you are already distributing your app to Wear 1.0 watches, follow these steps:
To ensure that a standalone APK acts as an upgrade to an embedded Wear APK, the standalone Wear APK's version code generally should be higher than the embedded Wear APK's version code. (A phone APK's version code scheme can be independent from that of a watch APK, although they must be unique.) However, the version codes of the standalone APK and the embedded Wear APK can be the same if the APKs are equivalent. If the APKs are not equivalent, but the version code is the same, then when a watch updates from Wear 1.0 to 2.0, the watch may get the new APK only after waiting for a longer-than-expected period of time.
Note that it currently is not possible to create a single APK that works on a phone and watch.
If you have a Wear app that is intended for both Wear 1.0 and Wear 2.0,
consider using
product flavors. For example,
if you want to target both SDK version 23 and version 24,
update your Wear module's build.gradle
file to include
the following if an existing embedded app has a minimum SDK version of 23:
android { // Allows you to reference product flavors in your // phone module's build.gradle file publishNonDefault true ... defaultConfig { // This is the minSdkVersion of the Wear 1.0 embedded app minSdkVersion 23 ... } buildTypes {...} productFlavors { wear1 { // Use the defaultConfig value } wear2 { minSdkVersion 24 } } }
Then update your phone module’s build.gradle
file, replacing
wearApp
as follows:
dependencies { ... wearApp project(path: ':wear', configuration: 'wear1Release') }
A
build variant is a combination of the product flavor and build type.
In Android Studio, select the appropriate build variant when
debugging or publishing your app. For example, if wear2
is a
product flavor, select wear2Release as the
release build variant.
For purposes of code that is Wear 2.0-specific or Wear 1.0-specific, consider source sets for build variants.
In your Android Manifest file, you must specify the following feature
restriction: the uses-feature
element is set to
android.hardware.type.watch
. Do not set
the required
attribute to false
.
A single APK for Wear and non-Wear devices presently is not supported.
Thus, if an APK has the following setting, Google Play provides the APK to watches only:
<manifest package="com.example.standalone" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-feature android:name="android.hardware.type.watch" ... </manifest>
The android.hardware.type.watch
setting above can be
combined with other criteria such as SDK version, screen resolution, and
CPU architecture. Thus, different Wear APKs can target different hardware
configurations.
Below is an introduction to uploading a standalone Wear APK to an application listing using the Play Developer Console.
If your app supports both Wear 1.0 and Wear 2.0, continue embedding the Wear 1.0 APK (minimum SDK version of 20, 21, or 22, or 23) in the phone APK and upload the phone APK. In addition, upload your standalone Wear 2.0 APK (which has a minimum SDK version of 24).
Also see Multiple APK Support and Manage Your App. Before uploading an APK as described below, the APK must be signed.
Go to the Play Developer Console, navigate to your application listing, and select APK in the left-navigation panel. An APK screen similar to the following is displayed:
You may need to use advanced mode for uploads, as follows:
Therefore, on the above APK screen, to determine whether to click the Switch to advanced mode button, consider the following:
See Simple mode and advanced mode for more information about toggling between modes.
Select the appropriate tab (Production, Beta Testing, or Alpha Testing) for your upload. Then click the Upload New APK button and select your standalone Wear APK for upload.
After you upload your standalone Wear APK and scroll down the resulting page, the APK is shown in the Current APK table, with a version number, in a similar way to the following:
Finally, in the Current APK table above, click the line with the Version to review the APK. The APK Details panel is displayed. You can verify, for example, that the number in the Supported Android Devices line is far fewer than the number would be for a typical phone APK:
When you are ready, publish your app.