Android Wear 2.0 支持表盘应用
Android Wear 2.0 support for watch face app
我有一个 Android 表盘应用程序,它同时具有移动和穿戴模块。
我想让这个应用程序准备好进行 2.0 更新,并且我已经访问了 Android 开发人员建议的所有网站,我了解几乎所有即将发生变化的事情,但后来变成了现实,我'我坚持了第一个简单的步骤。
据我阅读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
那么here我们有:
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).
既然我想继续支持 Android 1.x,我该怎么做呢?
如何在模块中设置SDK版本号?
我是否需要使用更改后的 SDK 版本复制穿戴模块以构建单独的穿戴式 apk?
任何成功完成并会提供使应用程序与当前和即将推出的 Wear 版本兼容的所有必要步骤的人的金币和王国。
好的,我仍然需要确认我所做的是否有效,但它应该符合文档要求,并且应用程序已经上传到 Play 控制台,没有任何错误。
可穿戴清单文件的变化
<uses-feature android:name="android.hardware.type.watch" />
<application ...>
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
...
</application>
可穿戴设备的变化 Gradle 文件
// 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 版本:
- 编译和目标 = 25,
- default min = 20 (for wear 1.x),
- min for wear 2.0 = 24
版本代码:wear 2.0 apk 需要比嵌入式可穿戴模块更大的数量。
NOTE that you need separate product flavors: wear1
and wear2
. You can use custom naming.
移动Gradle文件中的变化
// 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 版本:
- 编译和目标 = 25,
- 分钟=18
版本代码:与嵌入式可穿戴设备 (1) 相同。
NOTE that you need to specify the configuration
parameter of wearApp project()
using product flavor for embeded apk, adding "Release" build type: wear1Release
生成签名的 APK
- 在两个 APK 中使用相同的签名证书,
- 一如既往地生成移动 APK,
- 使用可穿戴模块生成可穿戴 APK(您将获得每种产品口味的 apk 文件)。
正在将 APK 上传到 Google 播放
- 切换到高级模式,
- 上传移动 apk 和
wear2
可穿戴 apk。
我有一个 Android 表盘应用程序,它同时具有移动和穿戴模块。
我想让这个应用程序准备好进行 2.0 更新,并且我已经访问了 Android 开发人员建议的所有网站,我了解几乎所有即将发生变化的事情,但后来变成了现实,我'我坚持了第一个简单的步骤。
据我阅读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
那么here我们有:
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).
既然我想继续支持 Android 1.x,我该怎么做呢?
如何在模块中设置SDK版本号?
我是否需要使用更改后的 SDK 版本复制穿戴模块以构建单独的穿戴式 apk?
任何成功完成并会提供使应用程序与当前和即将推出的 Wear 版本兼容的所有必要步骤的人的金币和王国。
好的,我仍然需要确认我所做的是否有效,但它应该符合文档要求,并且应用程序已经上传到 Play 控制台,没有任何错误。
可穿戴清单文件的变化
<uses-feature android:name="android.hardware.type.watch" />
<application ...>
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
...
</application>
可穿戴设备的变化 Gradle 文件
// 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 版本:
- 编译和目标 = 25,
- default min = 20 (for wear 1.x),
- min for wear 2.0 = 24
版本代码:wear 2.0 apk 需要比嵌入式可穿戴模块更大的数量。
NOTE that you need separate product flavors:
wear1
andwear2
. You can use custom naming.
移动Gradle文件中的变化
// 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 版本:
- 编译和目标 = 25,
- 分钟=18
版本代码:与嵌入式可穿戴设备 (1) 相同。
NOTE that you need to specify the
configuration
parameter ofwearApp project()
using product flavor for embeded apk, adding "Release" build type:wear1Release
生成签名的 APK
- 在两个 APK 中使用相同的签名证书,
- 一如既往地生成移动 APK,
- 使用可穿戴模块生成可穿戴 APK(您将获得每种产品口味的 apk 文件)。
正在将 APK 上传到 Google 播放
- 切换到高级模式,
- 上传移动 apk 和
wear2
可穿戴 apk。