由于本人英文能力实在有限,不足之初敬请谅解
本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接
Packaging Wearable Apps
打包穿戴设备app
When publishing to users, you must package a wearable app inside of a handheld app,
because users cannot browse and install apps directly on the wearable.
If packaged properly, when users download the handheld app, the system automatically pushes the wearable app to the paired wearable.
Note: This feature doesn't work when you are signing your apps with a debug key when developing.
While developing, installing apps with adb install or Android Studio directly to the wearable is required.
当发布给用户的时候,你必须打包一个穿戴设备app到一个手持设备app中,因为用户不会直接在穿戴设备上浏览并安装app。
如果打包恰当,当用户下载手持设备app时,系统会自动的把穿戴设备app安装到配对的穿戴设备中
注意:开发的时候,这个功能不能用在debug签名的app中。
开发的时候,必须通过adb install或者Android Studio直接安装到穿戴设备中。
Package with Android Studio
通过Android Studio打包
To properly package a wearable app in Android Studio:
在Android Studio中正确的打包一个穿戴设备app
1.Include all the permissions declared in the manifest file of the wearable app module in the manifest file of the handheld app module.
For example, if you specify the VIBRATE permission for the wearable app, you must also add that permission to the handheld app.
在手持设备app模块的manifest文件中要包含所有穿戴设备模块app的manifest中的所有声明的权限。
比如,如果你在穿戴设备app中指定了震动权限,那么你必须也在手持设备app中添加这个权限。
2.Ensure that both the wearable and handheld app modules have the same package name and version number.
确保穿戴设备app模块和手持设备app模块具有相同的包名和版本号。
3.Declare a Gradle dependency in the handheld app's build.gradle file that points to the wearable app module:
在手持设备app的build.gradle文件中声明一个Gradle依赖关系指向穿戴设备app模块:
dependencies { compile 'com.google.android.gms:play-services:5.0.+@aar' compile 'com.android.support:support-v4:20.0.+'' wearApp project(':wearable') }
4.Click Build > Generate Signed APK... and follow the on-screen instructions to specify your release keystore and sign your app.
Android Studio exports the signed handheld app with the wearable app embedded in it automatically into your project's root folder.
Alternatively, you can sign both apps from the command line using the Gradle wrapper.
Both apps must be signed to have the automatic pushing of the wearable app work.
Store your key file location and credentials in environment variables and run the Gradle wrapper as follows:
点击Build > Generate Signed APK... 然后根据屏幕上的说明来指定你的release keystore并且给你的app签名。
Android Studio自动导出内嵌穿戴设备app的手持设备app到你项目的根目录下。
或者,你可以使用Gradle wrapper从命令行签名这两个app。
两个app都必须签名,这样穿戴设备app才能自动安装。
在环境变量中保存你的文件位置和整数,然后运行下面的Gradle wrapper
./gradlew assembleRelease \ -Pandroid.injected.signing.store.file=$KEYFILE \ -Pandroid.injected.signing.store.password=$STORE_PASSWORD \ -Pandroid.injected.signing.key.alias=$KEY_ALIAS \ -Pandroid.injected.signing.key.password=$KEY_PASSWORD
Signing the wearable and handheld app separately
分别对穿戴设备app和手持设备app签名
If your build process requires signing the wearable app separately from the handheld app,
you can declare the following Gradle rule in the handheld module's build.gradle to embed the previously-signed wearable app:
如果你的编译进程需要单独签名穿戴设备app的话,你可以在手持设备模块的build.gradle中声明下面的Gradle规则来嵌入之前签名过的穿戴设备app:
dependencies { ... wearApp files('/path/to/wearable_app.apk') }
You then sign your handheld app in any manner you wish (either with the Android Studio Build > Generate Signed APK... menu item or with Gradle signingConfig rules as described in the previous section.
然后你再以你喜欢的方式签名(在Android Studio中 Build > Generate Signed APK... 菜单选项,或者使用上一章节所述的Gradle signingConfig规则)
Package Manually
手动打包
It's still possible to package the wearable app into the handheld app manually if you are using another IDE or another method of building.
如果你使用其他IDE或者其他编译方式的话,可以手动打包穿戴设备app到手持设备app中。
1.Include all the permissions declared in the manifest file of the wearable app in the manifest file of the mobile app.
For example, if you specify the VIBRATE permission for the wearable app, you must also add that permission to the mobile app.
移动app的manifest文件要包含所有穿戴设备app中manifest声明的权限。
比如,如果你在穿戴设备app中指定了震动权限,那么你必须也在手持设备app中添加这个权限。
2.Ensure that both the wearable and mobile APKs have the same package name and version number.
确保穿戴设备app模块和手持设备app模块具有相同的包名和版本号。
3.Copy the signed wearable app to your handheld project's res/raw directory. We'll refer to the APK as wearable_app.apk.
复制签名过的穿戴设备app到你的手持设备的res/raw目录下。我们将这个apk称为wearable_app.apk
4.Create a res/xml/wearable_app_desc.xml file that contains the version and path information of the wearable app. For example:
建立一个res/xml/wearable_app_desc.xml文件,包含穿戴设备app的版本和路径信息。例如:
<wearableApp package="wearable.app.package.name"> <versionCode>1</versionCode> <versionName>1.0</versionName> <rawPathResId>wearable_app</rawPathResId> </wearableApp>
The package, versionCode, and versionName are the same values specified in the wearable app's AndroidManifest.xml file.
The rawPathResId is the static variable name of the APK resource. For example, for wearable_app.apk, the static variable name is wearable_app.
package, versionCode和versionName要与穿戴设备appz中的AndroidManifest.xml文件里的值保持一致。
rawPathResId是apk资源的静态变量名。例如:对于wearable_app.apk来说,这个静态变量名就是wearable_app。
5.Add a meta-data tag to your handheld app's <application> tag to reference the wearable_app_desc.xml file.
添加meta-data标签到你的手持设备app的<application>标签中来引用wearable_app_desc.xml文件。
<meta-data android:name="com.google.android.wearable.beta.app" android:resource="@xml/wearable_app_desc"/>
6.Build and sign the handheld app.
编译并对手持设备app签名。
Turn off Asset Compression
关闭Asset压缩
Many build tools automatically compress any files added to the res/raw directory of an Android app.
Because the wearable APK is already zipped, these tools re-compress the wearable APK and the wearable app installer can no longer read the wearable app.
很多编译工具自动压缩Android app中所有在res/raw目录下的文件
因为穿戴设备apk已经是zip过的了,这些工具重写压缩穿戴设备apk,然后穿戴设备app安装器就不会再读取穿戴设备app了。
When this happens, the installation fails. On the handheld app, the PackageUpdateService logs the following error: "this file cannot be opened as a file descriptor; it is probably compressed."
当遇到这种情况的时候,安装会失败。在手持设备app中,PackageUpdateService会输出如下错误log:"this file cannot be opened as a file descriptor; it is probably compressed."
Android Studio doesn't compress your APK by default, but if you are using another build process, ensure that you don't doubly compress the wearable app.
Android Studio默认不会压缩你的apk,但是如果你使用其他编译进程,谨慎地确保你没有压缩穿戴设备app。
原文地址如下,英文水平实在有限,希望拍砖同时能给予指正。
https://developer.android.com/training/wearables/apps/packaging.html
转贴请保留以下链接
本人blog地址
相关推荐
智能穿戴制造-设备监控-工厂生产设备EMS解决方案.pptx
智能穿戴设备在现代科技生活中扮演着越来越重要的角色,特别是在Android平台上的应用开发。"智能穿戴设备Android-SDK,Ble中心设备例子.rar"是一个专为Android开发者提供的软件开发工具包,用于构建与智能穿戴设备...
在Android智能穿戴设备开发领域,开发者需要掌握一系列特定的知识点,以便从入门逐渐进阶到精通。本课程针对已有一定Android基础的学习者,旨在帮助他们拓宽技能树,深入理解穿戴设备的开发流程和技术要点。 首先,...
穿戴式设备-基于nRF52832开发的蓝牙智能手环项目源码.zip 【功能实现参考】 传感器数据采集与处理:通过配置并初始化LIS3DH、MAX30102、MPU6050等传感器,周期性读取传感器数据,并进行初步的滤波处理。 蓝牙通信:...
在探讨可穿戴设备的发展之路时,本文首先提出了几个核心问题,这些问题正是可穿戴技术领域不断追问和解决的方向。许永硕在ELEC沙龙天津站的演讲中,以问题驱动的方式,深入浅出地分析了可穿戴设备从起步到未来的可能...
8. **Inter-App Communication**:穿戴设备与手机间的通信是关键,源码可能会演示如何实现这种通信,如通过Google Play Services的 Wearable DataApi 或者MessageApi。 9. **Watch Faces**:自定义表盘是穿戴设备的...
Android智能穿戴设备开发指南,可穿戴越来越流行,有兴趣的可以看看
在Android智能穿戴设备开发中,开发者需要理解和掌握一系列关键技术,以构建高效、用户友好的可穿戴应用。本文将深入解析Android智能穿戴设备的代码实现,包括核心组件、API使用、用户体验设计以及与其他设备的交互...
MTK平台穿戴设备app源码,蓝牙推送 安装VXP文件
智能穿戴制造-设备监控-基站设备电力管理解决方案.pptx
【G011】智能穿戴制造-设备监控-工厂生产设备EMS解决方案主要探讨的是如何利用物联网技术提高工厂自动化和智能化水平,以实现更高效、更精确的设备管理和生产监控。该解决方案由日海物联解决方案公司提供,其核心是...
【G008】智能穿戴制造-设备监控-基站设备电力管理解决方案.pptx
在Android智能穿戴设备开发领域,Android Socket编程是构建智能眼镜和其他智能穿戴设备应用程序的重要组成部分。本文将深入探讨这个主题,并围绕“智能眼镜”、“智能”、“Android”、“智能穿戴”等标签,阐述相关...
智能穿戴制造-设备监控-物联指纹锁解决方案.pptx
智能穿戴制造-设备监控-工业物联网行业解决方案.pptx
【标题】: "Microchip 微芯_可穿戴设备-综合文档" 涉及的知识点 【描述】: Microchip Technology Inc., 或称微芯科技,是一家专注于半导体解决方案的公司,尤其在微控制器(MCU)、模拟集成电路(IC)和无线技术...
智能穿戴制造-设备监控-智能光交锁解决方案.pptx