ウォッチフェイスをデバッグする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、Watch Face Format でビルドされたウォッチフェイスをデバッグする方法について説明します。また、ウォッチフェイスの XML を検証してランタイム エラーを特定する方法についても説明します。
有効な Watch Face Format ドキュメントを確認する
Watch Face Format では、公開されている XSD に準拠した整形式の XML が必要となるため、ウォッチフェイスが有効かどうかを確認したり、エラーを特定したりできます。
XML 検証ツールを使用して、ビルドプロセス中に問題を特定します。このツールは、サンプルのウォッチフェイスのビルドプロセスに統合されています。
ウォッチフェイスの作成ツールを構築する場合は、ツールで XSD を使用して XML 検証を実行するようにしてください。
検証ツールを手動で実行する例:
java -jar wff-validator.jar 2 ~/MyWatchface/res/raw/watchface.xml
watchface.xml
ドキュメントにエラーがある場合は、エラーが表示されます。この例では、height
が hight
と誤って入力されています。
INFO: DWF Validation Application Version 1.0. Maximum Supported Format Version #2
SEVERE: [Line 41:Column 53]: cvc-complex-type.3.2.2: Attribute 'hight' is not allowed to appear in element 'PartDraw'.
INFO: ❌ FAILED : watchface.xml is NOT valid against watch face format version #1
バリデータは、修正が必要な要素の位置(行 41、列 53)を特定します。
XML バリデータ ツールを入手してビルドして使用する方法を学習します。
ランタイム エラーを特定する
XML 自体が有効であることを確認するだけでは、潜在的な問題をすべて検出することはできません。
たとえば、XML で存在しないフォントまたはドローアブル リソースを参照している場合や、数値が期待される式で文字列が返される場合などです。
このような問題の場合、Android Studio または ADB で logcat を使用すると、より詳細な情報を取得できます。
[ランタイム] でフィルタすると、ウォッチフェイスに影響する致命的な問題と致命的でない問題の両方を確認できます。たとえば、存在しない HourHand
のリソースを指定する場合は、次のようにします。
E Invalid resource ID 0x00000000.
E FATAL EXCEPTION: main
Process: com.google.wear.watchface.runtime, PID: 29115 android.content.res.Resources$NotFoundException: Resource ID #0x0
スペルミスのあるカラーテーマを使用する場合も同様です。
W color has wrong type of source:CONFIGURATION.myTheeeme.2[OBJECT:]
E Cannot parse theme color. Using theme color WHITE
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Debug a watch face\n\nThis page describes how to debug a watch face built with the Watch Face Format.\nIt also explains how to validate your watch face XML and identify runtime\nerrors.\n\nCheck for valid Watch Face Format documents\n-------------------------------------------\n\nAs the Watch Face Format requires well-structured XML that conforms to a\npublished XSD, you can confirm whether your watch face is valid or not,\nand identify errors.\n\nUse the [XML validation tool](https://github.com/google/watchface/tree/main/third_party/wff) to identify issues during the build\nprocess. This tool is integrated into the build process in the [sample watch\nfaces](https://github.com/android/wear-os-samples/tree/main/WatchFaceFormat).\n\nIf you are building a tool for creating watch faces, be sure that the tool\nperforms XML validation [using the XSD](https://github.com/google/watchface/tree/main/third_party/wff/specification/documents) in your tool.\n\nAn example of running the validation tool manually: \n\n java -jar wff-validator.jar 2 ~/MyWatchface/res/raw/watchface.xml\n\nIf there is an error in your `watchface.xml` document, you'll see an error, such\nas in this case where `height` has been misspelled as `hight`: \n\n INFO: DWF Validation Application Version 1.0. Maximum Supported Format Version #2\n SEVERE: [Line 41:Column 53]: cvc-complex-type.3.2.2: Attribute 'hight' is not allowed to appear in element 'PartDraw'.\n INFO: ❌ FAILED : watchface.xml is NOT valid against watch face format version #1\n\nThe validator identifies the location---line 41, column 53---of the element that\nneeds to be corrected.\n\nLearn how to [obtain the XML validator tool](https://github.com/google/watchface/blob/main/third_party/wff/README.md) and build it for\nuse.\n\n### Identify runtime errors\n\nEnsuring the XML itself is valid is not enough to capture all potential issues.\n\nFor example, your XML might reference a font or drawable resource that does not\nexist, or an expression might be expected to produce a numeric value, but\ninstead results in a string.\n\nFor these types of issues, using logcat, either in Android Studio or through ADB\nis a good way to get more detailed information.\n\nFilter on \"runtime\" and you'll be able to see both fatal and nonfatal issues\naffecting the watch face. For example, here, when specifying a resource for\n`HourHand` which does not exist: \n\n E Invalid resource ID 0x00000000.\n E FATAL EXCEPTION: main\n Process: com.google.wear.watchface.runtime, PID: 29115 android.content.res.Resources$NotFoundException: Resource ID #0x0\n\nOr here, when trying to use a color theme with a typo in it: \n\n W color has wrong type of source:CONFIGURATION.myTheeeme.2[OBJECT:]\n E Cannot parse theme color. Using theme color WHITE"]]