Wear OS アプリをデバッグする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
スマートウォッチの実機で Wear OS アプリをデバッグするには、Wi-Fi または Bluetooth を使用して開発マシンをスマートウォッチに接続します。または、スマートウォッチに USB ポートがある場合は、USB で接続します。
アプリでこのサポートが必要な場合、スマートウォッチやスマートフォンなど複数のデバイスにまたがるワークフローをテストすることもできます。テスト用の接続の設定方法について詳しくは、スマートウォッチをスマートフォンに接続するをご覧ください。
注: スマートウォッチの実機がない場合は、Android Studio のエミュレータでアプリを実行、テストすることもできます。
Wear OS の最新バージョンに更新する
アプリが最新のソフトウェアで正常に動作することを確認できるよう、テストデバイスに、対応する最新バージョンの Wear OS が搭載されていることをご確認ください。
テストデバイスにシステム アップデートがあるかどうかを確認するには:
- デバイスを Wi-Fi ネットワークに接続します。
- デバイスの充電を開始します。
- デバイスのバッテリーが 50% 以上充電されるまで待ちます。
-
テストデバイスで、[設定] > [システム] > [システム アップデート] に移動します。
適用できるシステム アップデートがあれば、テストデバイスにダウンロードされてインストールされます。
特定バージョンの Wear OS をインストールする(省略可)
アプリのテストケースが特定のバージョンの Wear OS に依存している場合は、USB データ接続をサポートするスマートウォッチにソフトウェア イメージを書き込むことができます。対象
たとえば、
ファクトリー イメージ
または
フル OTA イメージ
Google Pixel Watch 3 または Google Pixel Watch 2 デバイス。
スマートウォッチで開発者向けオプションを有効にする
スマートウォッチでデバッグを行うには、開発者向けオプションを有効にします。この操作は 1 回だけ行う必要があります。開発者向けオプションは、無効にするまで有効な状態で保持されます。開発者向けオプションを有効にする手順は次のとおりです。
- スマートウォッチの [設定] を開きます。
- [システム] > [デバイス情報] > [バージョン] をタップします。
- [ビルド番号] を 7 回タップします。
- 開発者向けオプションが有効になったことを確認するメッセージが表示されます。
Wi-Fi 経由でデバッグする
デバッグを開始する前に、前述のようにスマートウォッチで開発者向けオプションを有効にします。
スマートウォッチを Wi-Fi ネットワークに接続する
- スマートウォッチの [設定] を開きます。
- [接続] > [Wi-Fi] をタップします。
- ネットワークを選択し、必要に応じてパスワードを入力します。
注: スマートウォッチと開発マシンが同じネットワークに接続されている必要があります。すべてのアクセス ポイントが適切とは限りません。場合によっては、ファイアウォールが adb
をサポートするように適切に構成されているアクセス ポイントを使用する必要があります。
Wi-Fi 経由のデバッグを有効にする
- スマートウォッチの [設定] を開きます。
- [開発者向けオプション] > [Wi-Fi 経由でデバッグ] をタップします。
- しばらくすると、スマートウォッチの IP アドレス(
192.168.1.100
など)が画面に表示されます。この IP アドレスは次のステップで必要になるため、メモしておきます。
デバッガとスマートウォッチをペア設定する
- Wear OS デバイスで、システム設定のワイヤレス デバッグ オプションを確認します。[新しいデバイスとペア設定] を選択します。
- Wi-Fi ペア設定コードと IP アドレスとポートをメモします。
- 開発マシンのターミナル ウィンドウで次のコマンドを実行します。
adb pair IP_ADDRESS:PORT
-
プロンプトが表示されたら、ステップ 2 の Wi-Fi ペア設定コードを入力します。ペア設定が成功したかどうかがターミナルに出力されます。以下は例です。
Enter pairing code: 123456
Successfully paired to 192.168.1.100:5555
ペア設定が完了すると、Wear OS デバイスの
ワイヤレス デバッグ画面で、
ペア設定したデバイスのリストにホスト コンピュータが表示されます。
デバッガをスマートウォッチに接続する
- スマートウォッチと開発マシンを同じネットワークに接続します。
スマートウォッチの IP アドレスとポート番号を使用して、デバッガをスマートウォッチに接続します。たとえば、IP アドレスが 192.168.1.100
でポート番号が 5555
である場合、adb connect
コマンドとそのレスポンスは次のようになります。
adb connect 192.168.1.100:5555
connected to 192.168.1.100:5555
これでスマートウォッチがデバッガに接続されたので、デバッグを開始できます。-s
フラグを使用してスマートウォッチの IP アドレスとポート番号を指定し、adb
コマンドをスマートウォッチに送信します。
adb -s 192.168.1.100:5555 <command>
エミュレータを使用しておらず、デバッグ用に接続されているデバイスが 1 台のみの場合、アドレスの指定は不要です。
adb <command>
Bluetooth 経由でデバッグする
注: Bluetooth 経由のデバッグは、Wear OS 2 を搭載し、Android とペア設定されたスマートウォッチでのみ機能します。
デバッグを開始する前に、スマートウォッチとスマートフォンをペア設定し、前述のようにスマートウォッチで開発者向けオプションを有効にします。スマートフォンの [設定] メニューを開き、[開発者向けオプション] を見つけて、スマートフォンで開発者向けオプションが有効になっていることを確認します。必要な場合は、スマートフォンで開発者向けオプションを有効にします。
スマートフォンで USB デバッグを有効にする
- スマートフォンの [設定] メニューを開きます。
- [開発者向けオプション] を選択し、[USB デバッグ] を有効にします。
スマートウォッチで ADB デバッグと Bluetooth 経由のデバッグを有効にする
- スマートウォッチの [設定] メニューを開きます。
- [開発者向けオプション] までスクロールします。
- [ADB デバッグ] が有効になっていることを確認します。
- [Bluetooth 経由でデバッグ] を有効にします。
スマートフォンで Bluetooth 経由のデバッグを有効にする
- スマートフォンで Wear OS コンパニオン アプリを開きます。
- [詳細設定] まで下にスクロールし、タップして [詳細設定] のオプションを表示します。
- [Bluetooth 経由のデバッグ] を有効にします。オプションの下に、次のステータス メッセージが表示されます。
Host: disconnected
Target: connected
この時点では、開発マシン(ホスト)はスマートウォッチ(ターゲット)と通信していません。通信を開始するには、リンクを完了する必要があります。
注: デバッグは一度に 1 台のみ行うことができます。複数のスマートウォッチがペア設定されている場合、Bluetooth 経由のデバッグはメイン画面で選択したデバイスでのみ有効になります。
デバッガをスマートウォッチに接続する
この最後の手順では、デバッガ、スマートフォン、スマートウォッチをすべて使用します。
- USB ケーブルでスマートフォンを開発マシンに接続します。
- デバッガで次の 2 つのコマンドを実行します。
adb forward tcp:4444 localabstract:/adb-hub
adb connect 127.0.0.1:4444
注: IP アドレス 127.0.0.1 を使用する必要があります。開発マシンで任意の使用可能なポートを使用し、両方のコマンドで同じポートを使用します。この例のポートは 4444 です。
- 接続コマンドを入力すると、スマートウォッチで、ADB デバッグを許可していることを確認するよう求められます。
- スマートフォンで、Wear OS コンパニオン アプリのステータスが次のように表示されていることを確認します。
Host: connected
Target: connected
これでスマートウォッチがデバッガに接続されたので、デバッグを開始できます。
Bluetooth を使用してスマートウォッチをデバッグする場合、adb
では必ず IP アドレス 127.0.0.1
と割り当てたポートを使用します。この例のポートは 4444
です。すべての adb
コマンドは次の形式を使用します。
adb -s 127.0.0.1:4444 <command>
エミュレータを使用しておらず、デバッグ用に接続されているデバイスが 1 台のみの場合、アドレスの指定は不要です。
adb <command>
Wear OS でスクリーン レコードを使用する
macOS で開発を行っている場合は、GitHub プロジェクトの Mac 向け Android ツールを使用して、Wear OS デバイスで動画を録画できます。
または、次の手順で Wear OS デバイスから動画を録画します。
- スマートウォッチで RAW フレームを録画します。
adb shell screenrecord --time-limit 30 --output-format raw-frames --verbose /sdcard/video.raw
- RAW ファイルを開発マシンにコピーします。
adb pull /sdcard/video.raw video.raw
ffmpeg
を使用して RAW ファイルを MP4 に変換します。ffmpeg -f rawvideo -vcodec rawvideo -s 400x400 -pix_fmt rgb24 -r 10 -i video.raw -an -c:v libx264 -pix_fmt yuv420p video.mp4
注: ダウンロードとインストールの手順については、FFmpeg のウェブサイトをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-26 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-26 UTC。"],[],[],null,["# Debug a Wear OS app\n\nTo debug your Wear OS app on a physical watch, connect your development machine to the watch using\nWi-Fi or Bluetooth. Alternatively, if your watch has a USB port,\n[connect using USB](/training/wearables/apps/creating#connect-watch-wired).\n\n\nYou can also test workflows that span multiple devices, such as a watch and a\nphone, if your app requires this support. To learn more about how to set up\na connection for testing, visit\n[connect a watch to a\nphone](/training/wearables/get-started/connect-phone).\n\n**Note:** If you don't have a physical watch, you can also\ntest and [run\nyour app on an emulator](/training/wearables/get-started/creating#run-emulator) in Android Studio.\n\nUpdate to the latest version of Wear OS\n---------------------------------------\n\nTo help verify that your app behaves as expected on the latest software,\ncheck that your test device is running the most up-to-date version of Wear OS\nthat your device supports.\n\nTo check for a system update on your test device, complete these steps:\n\n1. Connect the device to a Wi-Fi network.\n2. Start charging the device.\n3. Wait for the device's battery to charge to 50% or higher.\n4. On your test device, navigate to\n **Settings \\\u003e System \\\u003e System updates**.\n\n If a system update is available, it'll be downloaded and installed onto\n your test device.\n\n### Install a specific version of Wear OS (optional)\n\nIf your app's test case depends on a specific version of Wear OS, you can\nflash a software image onto watches that support a USB data connection. For\nexample, you can flash a\n[factory image](https://developers.google.com/android/images-watch)\nor a\n[full OTA image](https://developers.google.com/android/ota-watch)\nonto a Google Pixel Watch 3 or Google Pixel Watch 2 device.\n\nEnable developer options on your watch\n--------------------------------------\n\nBefore you can debug on your watch, enable developer options.\nYou only need to do this one time. Developer options remain enabled until\nyou disable them. To enable developer options, do the following:\n\n1. Open the watch's **Settings**.\n2. Tap **System \\\u003e About \\\u003e Versions**.\n3. Tap the **Build number** item seven times.\n4. A message appears confirming that you are now a developer.\n\nDebug over Wi-Fi\n----------------\n\nBefore you begin, enable developer options on the watch as described previously.\n\n### Connect the watch to a Wi-Fi network\n\n1. Open the watch's **Settings**.\n2. Tap **Connectivity \\\u003e Wi-Fi**.\n3. Choose a network and enter its password if necessary. **Note:**\n The watch and your development machine must be connected to the same network. Not all\n access points are suitable. You may need to use an access point whose firewall is configured\n properly to support `adb`.\n\n### Enable Wi-Fi debugging\n\n1. Open the watch's **Settings**.\n2. Tap **Developer options \\\u003e Debug over Wi-Fi**.\n3. After a moment, the screen displays the watch's IP address, such as `192.168.1.100`. You need this for the next step, so make a note of it.\n\n### Pair the debugger to the watch\n\n1. On your Wear OS device, find the wireless debugging options in system settings. Select **Pair new device**.\n2. Note the **Wi-Fi pairing code** and the **IP address \\& port.**\n3. In a terminal window on your development machine, type the following command: \n\n ```bash\n adb pair IP_ADDRESS:PORT\n ```\n4. When prompted, enter the Wi-Fi pairing code from step 2. The terminal will output whether pairing was successful. As an example: \n\n ```\n Enter pairing code: 123456\n Successfully paired to 192.168.1.100:5555\n ```\n\nAfter pairing, the host computer appears in the list of **Paired devices** on your Wear OS device's **Wireless Debugging** screen.\n\n### Connect the debugger to the watch\n\n1. Connect your watch and development machine to the same network.\n2. Connect the debugger to the watch using the watch's IP address and a port\n number. For example, if the IP address is\n `192.168.1.100` and the port number is `5555`, the\n `adb connect` command and its response look like this:\n\n ```\n adb connect 192.168.1.100:5555\n connected to 192.168.1.100:5555\n ```\n\nThe watch is now connected to the debugger and you are ready to start debugging.\nSend `adb` commands\nto the watch using the `-s` flag, specifying the watch's IP address and\nthe port number: \n\n```\nadb -s 192.168.1.100:5555 \u003ccommand\u003e\n```\n\nIf you are not using the emulator and have only one device connected for debugging, you don't\nneed to specify the address: \n\n```\nadb \u003ccommand\u003e\n```\n\nDebug over Bluetooth\n--------------------\n\n**Note**: Bluetooth debugging works only for Android-paired\nwatches running Wear OS 2.\n\nBefore you\nbegin, pair the watch and phone and enable [developer options](#enable-dev-options) on\nthe watch as described previously. Check that developer options are enabled on the\nphone by opening the phone's\n**Settings** menu and looking for **Developer Options** .\nIf necessary, [enable developer\noptions](/studio/debug/dev-options#enable) on the phone.\n\n### Enable USB debugging on the phone\n\n1. Open the phone's **Settings** menu.\n2. Select **Developer Options** and enable **USB debugging**.\n\n### Enable ADB or Bluetooth debugging on the watch\n\n1. Open the watch's **Settings** menu.\n2. Scroll to **Developer Options**.\n3. Confirm that **ADB debugging** is enabled.\n4. Enable **Debug over Bluetooth**.\n\n### Enable Bluetooth debugging on the phone\n\n1. On the phone, open the Wear OS companion app.\n2. Scroll to **Advanced Settings** and tap to view the **Advanced Settings** options.\n3. Enable **Debugging over Bluetooth** . The following status message appears under the option: \n\n ```\n Host: disconnected\n Target: connected\n ```\n\nAt this point the development machine---the host---is not communicating with\nthe watch---the target. You need to complete the link.\n\n**Note**: You can only debug with one device at a time.\nIf you have multiple watches paired, Bluetooth debugging is only enabled\nwith the device selected on the main screen.\n\n### Connect the debugger to the watch\n\nIn this final step, you use everything: the debugger, the phone, and the watch.\n\n1. Connect the phone to your development machine with a USB cable.\n2. Run these two commands in the debugger: \n\n ```\n adb forward tcp:4444 localabstract:/adb-hub\n adb connect 127.0.0.1:4444\n ```\n\n **Note**: You must use the IP address 127.0.0.1. Use any available port\n on your development machine, and use the same port in both commands. In this example, the\n port is 4444.\n3. After you enter the connect command, the watch asks you to confirm that you are allowing **ADB Debugging**.\n4. On the phone, check the status display in the Wear OS companion app for the following: \n\n ```\n Host: connected\n Target: connected\n ```\n5. The watch is now connected to the debugger, and you're ready to start debugging.\n\nWhen you debug a watch using Bluetooth, `adb` always uses the IP address `127.0.0.1`\nplus the port that you assign. In this example, the port is `4444`. All `adb` commands use the\nfollowing format: \n\n```\nadb -s 127.0.0.1:4444 \u003ccommand\u003e \n```\n\nIf you are not using the emulator and have only one device connected for debugging, you don't\nneed to specify the address: \n\n```\nadb \u003ccommand\u003e\n```\n\nUse screen record for Wear OS\n-----------------------------\n\nIf you develop on macOS, you can use the GitHub project\n[Android tool for Mac](https://github.com/mortenjust/androidtool-mac/blob/master/README.md) to record a video from your Wear OS device.\n\nAlternatively, record a video from your Wear OS device using the following steps:\n\n1. Record raw frames on the watch: \n\n ```\n adb shell screenrecord --time-limit 30 --output-format raw-frames --verbose /sdcard/video.raw\n ```\n2. Copy the raw file to your development machine: \n\n ```\n adb pull /sdcard/video.raw video.raw\n ```\n3. Use `ffmpeg` to convert the raw file to MP4: \n\n ```\n ffmpeg -f rawvideo -vcodec rawvideo -s 400x400 -pix_fmt rgb24 -r 10 -i video.raw -an -c:v libx264 -pix_fmt yuv420p video.mp4\n ```\n\n **Note:**\n Refer to the [FFmpeg](https://www.ffmpeg.org/download.html) website for download and\n installation instructions.\n\n\nRefer to the following related resources:\n\n- [Android Debug Bridge (adb)](/studio/command-line/adb)\n- [Debug your app](/studio/debug)\n- [Design principles](/training/wearables/design/design-principles)\n- [Capture Wear UI screens](/training/wearables/get-started/screenshots)"]]