Adding Android Wear Component To existing Android Studio
In this post I will try to describe how Android Wear component can be added to an existing Android project in Android Studio.
Android Wear applications do not have it’s own Play Store because they can not be installed directly from Android Wear wathches. Android Wear applications are packaged inside standard application for Android phones. That means that APK for wearables is packaged inside APK for phones. An user installs an application using Google Play Store, as any other application for his phone, and the phone automatically installs Android Wear component on connected Android Wear device.
Existing Android project in Android Studio can be easily expanded with an Android Wear component.
Adding an Android Wear component to Android project in Android Studio is made by creating a new module in the project by selecting File -> New Module…
“Android Wear Module” should be selected as a new module’s type.
In the next step of creating a new module the “Minimum required SDK” should be set to “API20: Android 4.4 (KitKat Wear)”.
For a phone to be able to automatically install the Android Wear component on an Android Wear device, an application for a phone and the Android Wear application that is packaged inside have to be signed with the same signing key and to have the same package name. Because of that the new module that will represent Android Wear component in Android Studio project should be configured to have the same package name as the existing module (application for phones).
The next thing, after creating the new Android Wear module, is to add a new dependency in phone module’s build.gradle file.
1 2 3 |
|
This dependency instruction is needed for Wearable application to be packaged inside the phone app.
Only Release builds (assembleRelease) include wearable component inside phone app’s apk. Debug builds (assembleDebug) does not include wearable components, so when debugging, phone app and wearable app have to be installed separately.
Comments
Post a Comment