构建和部署表盘
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了使用表盘格式的表盘的结构,以及如何构建和部署表盘。
WFF 表盘的结构
表盘格式表盘与任何其他应用一样,都以 AAB 或 APK 的形式提交到 Play 商店。因此,它们具有许多与其他应用相同的常见属性(例如需要 AndroidManifest.xml
文件),但也具有特定的结构。
- 表盘的所有内容都位于 resources 文件夹中,即
res/
- 所有表盘定义均位于
res/raw/
中,包括简单用例的 res/raw/watchface.xml
,以及表示支持不同设备尺寸的任何其他 XML 定义。
- 与常规应用一样,表盘所需的所有资源都位于相应的资源文件夹中,例如:
/res/font
适用于字体
- 图片和动画素材资源的
/res/drawable
/res/values/strings.xml
(适用于任何字符串资源)
使用 Gradle 构建表盘主题
如需了解如何使用 Gradle 构建表盘,最简单的方法是查看 GitHub 上的示例。
除了构建表盘之外,这些项目中的 Gradle 脚本还会使用验证器工具检查表盘 XML 的有效性。
在提交到 Google Play 之前检查表盘主题
创建表盘主题并熟悉构建流程后,请先对表盘主题 AAB 执行提交前检查,然后再提交到 Play。
Play 会执行非常类似的检查,因此确保您通过这些提交前检查,可在提交和审核流程中节省大量时间。
运行提交前检查的示例:
这些检查不仅会检查表盘使用的内存量,还会找出其他问题(例如缺少资源),并验证 XML。
如需详细了解如何获取和构建该工具,请参阅内存占用空间评估器。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Build and deploy a watch face\n\nThis page describes the structure of watch faces that use the Watch Face Format,\nas well as how to build and deploy them.\n\nThe structure of WFF watch faces\n--------------------------------\n\nWatch Face Format watch faces are submitted to the Play Store as AABs or APKs just\nlike any other app. While they therefore share many of the common attributes of\nother apps, such as a need for an `AndroidManifest.xml` file, they have a specific\nstructure.\n\n1. All the content of the watch face is in the resources folder, namely `res/`\n2. All the watch face definitions are in `res/raw/`, including `res/raw/watchface.xml` for the simple case and any other XML definitions that represent support for different device sizes.\n3. All resources needed by the watch face are in the appropriate resources folder, just as for regular applications, for example:\n 1. `/res/font` for fonts\n 2. `/res/drawable` for image and animation assets\n 3. `/res/values/strings.xml` for any string resources\n\nBuild the watch face using Gradle\n---------------------------------\n\nThe easiest way to see the process of how to use Gradle to build the watch face\nis to take a look at the [samples on GitHub](https://github.com/android/wear-os-samples/tree/main/WatchFaceFormat).\n\nAs well as building the watch face, the Gradle scripts in these projects check\nthe watch face XML for validity using the [validator tools](/training/wearables/wff/setup#check_your_watch_face_correctness_and_performance).\n\nCheck the watch face prior to submission to Google Play\n-------------------------------------------------------\n\nOnce you have created your watch face and familiarized yourself with the build\nprocess, perform pre-submission checks on your watch face AAB before\nsubmitting to Play.\n\nPlay performs very similar checks, so ensuring that you're passing these\npre-submission checks saves you considerable time in the submission and\nreview process.\n\nAn example of running the pre-submission checks:\n\nThese checks no only inspect how much memory the watch face is using, but also\nidentify other issues, such as missing resources, as well as validating the\nXML.\n\nFor details on how to obtain and build the tool, see the\n[Memory Footprint Evaluator](https://github.com/google/watchface/tree/main/play-validations)."]]