Reputation: 2617
I have an Android watch face app that has both mobile and wear modules.
I want to get this app ready for 2.0 update, and I've visited all the websites that Android Developers suggest, I understand almost everything that's about to change, but then comes reality, and I'm stuck with a first simple steps.
As I read here:
If you build a standalone Wear 2.0 APK and will continue to have a Wear 1.0 APK, please do both of the following:
Provide a standalone version of the Wear APK, and Continue embedding a version of the Wear APK in your phone APK
Then here we have:
If your app supports both Wear 1.x and Wear 2.0, continue embedding the Wear 1.x 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).
So as I want to keep support for Android 1.x, what do I do exactly?
How do I set SDK version numbers in modules?
Do I need to duplicate wear module with changed SDK version for building a separate wearable apk?
Gold and kingdom for anyone that has done it successfully and would present all the necessary steps for making the app compatible for current and upcoming Wear versions.
Upvotes: 4
Views: 1455
Reputation: 2617
OK, I still have to confirm if what I've done works, but it should as it meets documentation and the app's already uploaded on Play console with no errors.
<uses-feature android:name="android.hardware.type.watch" />
<application ...>
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
...
</application>
// wearable module
dependencies {
compile 'com.google.android.support:wearable:2.0.0'
compile 'com.google.android.gms:play-services-wearable:10.0.1'
...
}
android {
compileSdkVersion 25
publishNonDefault true
buildToolsVersion "25.0.2"
defaultConfig {
applicationId = "com.example.watchface"
minSdkVersion 20
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
productFlavors {
wear1 {
}
wear2 {
minSdkVersion 24
versionCode 2 // +1 relatively to default value
}
}
...
}
SDK Versions:
Version codes: wear 2.0 apk will need bigger number than embeded wearable module.
NOTE that you need separate product flavors:
wear1
andwear2
. You can use custom naming.
// mobile module
dependencies {
compile 'com.google.android.support:wearable:2.0.0'
compile 'com.google.android.gms:play-services-wearable:10.0.1'
...
wearApp project(path:':Wearable', configuration: "wear1Release")
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId = "com.example.watchface"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
...
}
SDK Versions:
Version code: same as embeded wearable (1).
NOTE that you need to specify the
configuration
parameter ofwearApp project()
using product flavor for embeded apk, adding "Release" build type:wear1Release
wear2
wearable apk.Upvotes: 5