با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه راهنمای ساختن اولین برنامه خود را برای Wear OS با استفاده از الگوی Android Studio ارائه می دهد. این برنامه راههای مختلف مشاهده اطلاعات را در یک نگاه در دستگاههای Wear OS نشان میدهد و بهترین روشها را برای توسعه برنامهها در پلتفرم معرفی میکند.
پس از دانلود و نصب آخرین نسخه اندروید استودیو، جادوگر "پروژه جدید" را تکمیل کنید:
Android Studio را باز کنید و سپس به File > New > New Project بروید. پنجره پروژه جدید ظاهر می شود.
در قسمت Templates ، Wear OS را انتخاب کنید. سپس، در قسمت اصلی، Empty Wear App را انتخاب کنید.
نام پروژه خود را بگذارید و سپس روی Finish کلیک کنید. Android Studio وابستگی های لازم را دانلود می کند و نسخه اولیه پروژه شما را می سازد.
به Tools > SDK Manager بروید، روی Show Package Details کلیک کنید و بسته های زیر را نصب کنید:
Android 15.0 ("VanillaIceCream") (سطح API 35-ext15)، که شامل Wear OS 5.1 ARM 64 v8a System Image و Wear OS 5.1 Intel x86 Atom_64 System Image است .
Android 14.0 ("UpsideDownCake") (سطح API 34)، که شامل Wear OS 5 ARM 64 v8a System Image و Wear OS 5 Intel x86 Atom_64 System Image است .
Android 13.0 ("Tiramisu") (سطح API 33)، که شامل Wear OS 4 ARM 64 v8a System Image و Wear OS 4 Intel x86 Atom_64 System Image است .
برای بستن مدیر SDK، روی OK کلیک کنید.
اکنون آماده اجرای اولین برنامه خود در Wear OS هستید.
یک برنامه را روی شبیه ساز اجرا کنید
ساده ترین راه برای اجرای اولین برنامه Wear OS پیکربندی یک شبیه ساز است.
یک شبیه ساز را پیکربندی کنید
برای پیکربندی شبیه ساز در اندروید استودیو، مراحل زیر را انجام دهید:
در مدیر SDK، تب ابزار SDK را باز کنید. تأیید کنید که آخرین نسخه Android SDK Platform-Tools را دارید. مدیر SDK را ببندید.
به Tools > Device Manager بروید.
ایجاد (+) را انتخاب کنید. جادوگر پیکربندی دستگاه مجازی ظاهر می شود.
در قسمت دسته ، Wear OS را انتخاب کنید و نمایه سخت افزاری مانند Wear OS Small Round را انتخاب کنید. روی Next کلیک کنید.
برای تصاویر سیستمی که در خارج از چین استفاده می شوند، نام انتشار UpsideDownCake را انتخاب کنید. این نسخه اندروید 14.0 (Wear OS 5) را هدف قرار می دهد. برای تصاویر سیستم مورد استفاده در چین، نام انتشار R را انتخاب کنید. این نسخه اندروید 11.0 (Wear OS 3) را هدف قرار می دهد. اگر قبلاً تصویر سیستم Wear OS 5 را نصب نکردهاید که با تعریف دستگاه شما مطابقت داشته باشد، برای دریافت آن، روی Download در کنار Release Name کلیک کنید. روی Next کلیک کنید.
توجه: تصاویر سیستم برای شبیه ساز Wear OS شامل اعلان فایل های شخص ثالث و کد منبع است. میتوانید با باز کردن فایل NOTICE.txt که در یکی از دایرکتوریهای زیر است، اعلامیههای شخص ثالث را برای یک تصویر سیستمی خاص مشاهده کنید:
$ANDROID_HOME/system-images/android- API_VERSION_NUMBER /android-wear/ ABI برای شبیهسازهایی که در خارج از چین استفاده میشوند.
$ANDROID_HOME/system-images/android- API_VERSION_NUMBER /android-wear-cn/ ABI برای شبیه سازهای مورد استفاده در چین.
میتوانید مقدار پیشفرض را برای همه تنظیمات روی این صفحه نگه دارید، مگر اینکه بخواهید شبیهساز خود را سفارشی کنید. روی Finish کلیک کنید.
تصاویر اخیر سیستم فقط از معماری های 64 بیتی پشتیبانی می کنند
تصاویر سیستم شبیهساز برای Wear OS 4 و بالاتر فقط از این معماریهای 64 بیتی پشتیبانی میکنند: x86-64 و arm64-v8a . اگر می دانید یا مشکوک هستید که برنامه شما از کد بومی استفاده می کند (که به زبان های برنامه نویسی Kotlin یا جاوا نوشته نشده است)، بررسی کنید که برنامه شما دارای کتابخانه های بومی 32 بیتی و 64 بیتی باشد.
اجرای و اشکال زدایی برنامه خود روی یک ساعت واقعی به شما امکان می دهد تا کل تجربه کاربر را بهتر ارزیابی کنید. اگر برنامه شما به سخت افزار خاصی مانند سنسورها یا GPU متکی باشد، این امر به ویژه مهم است.
برای اجرای یک برنامه در ساعت فیزیکی، دستگاه را برای آزمایش آماده کنید و سپس آن را به دستگاه توسعه خود متصل کنید.
ساعت را برای آزمایش آماده کنید
برای آماده کردن ساعت خود برای آزمایش، اشکال زدایی ADB را با انجام مراحل زیر فعال کنید.
در ساعت، منوی تنظیمات را باز کنید.
به پایین منو بروید. اگر هیچ مورد گزینه Developer ظاهر نشد، مراحل فرعی زیر را کامل کنید. در غیر این صورت به مرحله بعد ادامه دهید.
روی System > About یا System > About > Versions ضربه بزنید.
مورد Build number را پیدا کنید و هفت بار روی آن ضربه بزنید. اگر ساعت شما توسط یک پین یا الگو محافظت می شود، زمانی که از شما خواسته شد آن را وارد کنید.
از منوی تنظیمات ، روی گزینههای برنامهنویس ضربه بزنید.
گزینه ADB debugging را فعال کنید.
ساعت را به ماشین توسعه وصل کنید
برخی از ساعت ها به شما امکان می دهند از طریق USB متصل شوید. برخی دیگر نیاز به اتصال بی سیم دارند.
یک اتصال سیمی از طریق USB تنظیم کنید
ساعت را با استفاده از مراحل زیر وصل کنید:
با استفاده از کابل USB، ساعت را به دستگاه توسعه خود وصل کنید.
در ساعت، همیشه از این رایانه مجاز باشد را فعال کنید و سپس روی تأیید ضربه بزنید.
اگر مورد آزمایشی برنامه شما به نسخه خاصی از Wear OS بستگی دارد، میتوانید یک تصویر نرمافزاری را روی ساعتهایی فلش کنید که از اتصال داده USB (سیمی) پشتیبانی میکنند. به عنوان مثال، میتوانید یک تصویر کارخانه یا یک تصویر کامل OTA را روی دستگاه Google Pixel Watch 3 یا Google Pixel Watch 2 فلش کنید.
برنامه را روی ساعت باز کنید
به Run > Select Device بروید. ساعتی را انتخاب کنید که به دستگاه شما متصل است.
در نوار ابزار Android Studio، روی Run کلیک کنید . شبیه ساز شروع می شود و برنامه شما را باز می کند.
پس از چند لحظه، باید پیام «سلام...» را روی ساعت مشاهده کنید.
{% کلمه به کلمه %} {% آخر کلمه %}
برای شما توصیه می شود
توجه: وقتی جاوا اسکریپت خاموش است، متن پیوند نمایش داده می شود
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Create and run an app on Wear OS\n\nThis page provides a guide for you to build your first app for Wear OS, using a\ntemplate from Android Studio. The app showcases the different ways to view\ninformation at a glance on Wear OS devices, and introduces some best practices\nfor developing apps on the platform.\n\nThis guide builds upon some prior knowledge about the Android platform and the\n[Android Studio IDE](/studio). If you're completely new to Android, [create an app\nusing this codelab](/codelabs/basic-android-kotlin-compose-first-app#1). To learn more about Android Studio's capabilities, visit\nthe [Meet Android Studio](/studio/intro) page.\n| **Note:** To use the latest system images that are available for the emulator, install Android Studio Hedgehog or later.\n\nCreate a Wear OS app\n--------------------\n\nAfter you download and install the latest version of Android Studio, complete\nthe \"new project\" wizard:\n\n1. Open Android Studio, and then go to **File \\\u003e New \\\u003e New Project** . The **New Project** window appears.\n2. In the **Templates** pane, select **Wear OS** . Then, in the main pane, select **Empty Wear App**.\n3. Name your project, and then click **Finish**. Android Studio downloads the necessary dependencies and builds the initial version of your project.\n4. Go to [**Tools \\\u003e SDK Manager**](/studio/intro/update#sdk-manager), click **Show Package Details**, and\n install the following packages:\n\n - **Android 15.0 (\"VanillaIceCream\")** (API level 35-ext15), which includes the **Wear OS 5.1 ARM 64 v8a System Image** and the **Wear OS 5.1 Intel x86 Atom_64 System Image**.\n - **Android 14.0 (\"UpsideDownCake\")** (API level 34), which includes the **Wear OS 5 ARM 64 v8a System Image** and the **Wear OS 5 Intel x86 Atom_64 System Image**.\n - **Android 13.0 (\"Tiramisu\")** (API level 33), which includes the **Wear OS 4 ARM 64 v8a System Image** and the **Wear OS 4 Intel x86 Atom_64\n System Image**.\n\n | **Note:** The latest stable version of Wear OS, Wear OS 5.1, is based on Android 15.\n\n To close the SDK Manager, click **OK**.\n\nYou're now ready to run your first app on Wear OS.\n| **Note:** By default, the **New Project** wizard creates a standalone, independent Wear OS app that doesn't need to connect to another device in order to run. \n|\n| A Wear OS app should work independently of a phone app, giving users the greatest flexibility in their choice of phones. If your app's experience or complexity requires you to connect to a phone, see the guide on how to [connect\n| a watch to a phone](/training/wearables/get-started/connect-phone).\n\nRun an app on the emulator\n--------------------------\n\nThe easiest way to run your first Wear OS app is to configure an emulator.\n| **Note:** If you plan to make your Wear OS apps available in China, also visit the [Create Wear OS apps for China](/training/wearables/apps/creating-app-china) page.\n\n### Configure an emulator\n\nTo configure an emulator in Android Studio, complete the following steps:\n\n1. In the SDK Manager, Open the **SDK Tools** tab. Confirm that you have the latest version of **Android SDK Platform-Tools**. Close the SDK Manager.\n2. Go to **Tools \\\u003e Device Manager**.\n3. Select **Create (+)** . The **Virtual Device Configuration** wizard appears.\n4. In the **Category** pane, select **Wear OS** and choose a hardware profile, such as **Wear OS Small Round** . Click **Next**.\n5. For system images used outside of China, select the **UpsideDownCake**\n release name. This release targets Android 14.0 (Wear OS 5). For\n system images used in China, select the **R** release name. This release\n targets Android 11.0 (Wear OS 3). If you don't already have a Wear OS 5\n system image installed that matches your device definition, click\n **Download** next to the **Release Name** to get it. Click **Next**.\n\n **Note:** System images for the Wear OS emulator include notices of\n third-party files and source code. You can view third-party notices for a\n particular system image by opening the `NOTICE.txt` file, which\n is in one of the following directories:\n - `$ANDROID_HOME/system-images/android-`\u003cvar translate=\"no\"\u003eAPI_VERSION_NUMBER\u003c/var\u003e`/android-wear/`\u003cvar translate=\"no\"\u003eABI\u003c/var\u003e for emulators used outside of China.\n - `$ANDROID_HOME/system-images/android-`\u003cvar translate=\"no\"\u003eAPI_VERSION_NUMBER\u003c/var\u003e`/android-wear-cn/`\u003cvar translate=\"no\"\u003eABI\u003c/var\u003e for emulators used in China.\n6. You can keep the default value for all the settings on this screen, unless\n you want to customize your emulator. Click **Finish**.\n\nFor more information about using emulators, see the guide about how to [run apps\non the Android Emulator](/studio/run/emulator).\n\n### Open the app in the emulator\n\n1. Go to **Run \\\u003e Select Device**. Choose the emulator that you just created.\n2. In the Android Studio toolbar, click **Run** . The emulator starts and opens your app.\n3. After a few moments, you should see a \"Hello...\" message in the emulator.\n\n### Test Bluetooth audio using the emulator\n\nOn system images the run Wear OS 4 or higher, the emulator supports emulated\nBluetooth, which lets you [test Bluetooth audio](/training/wearables/apps/test-bluetooth-audio) across several use cases.\n\n### Recent system images only support 64-bit architectures\n\nThe emulator system images for Wear OS 4 and higher only support these 64-bit\narchitectures: `x86-64` and `arm64-v8a`. If you know or suspect that your app\nuses native code (that isn't written in the Kotlin or Java programming\nlanguages), check that your app includes both 32-bit and 64-bit native\nlibraries.\n\nLearn more about how to [support 64-bit architectures](/google/play/requirements/64-bit).\n\nRun an app on a physical watch (optional)\n-----------------------------------------\n\nRunning and debugging your app on an actual watch lets you better evaluate the\ntotal user experience. This is particularly important if your app relies on\nspecific hardware, such as sensors or a GPU.\n\nTo run an app on a physical watch, prepare the device for testing, and then\nconnect it to your development machine.\n\n### Prepare watch for testing\n\nTo prepare your watch for testing, enable ADB debugging by completing the\nfollowing steps.\n\n1. On the watch, open the **Settings** menu.\n2. Go to the bottom of the menu. If no **Developer options** item appears, complete the following sub-steps. Otherwise, continue to the next step.\n 1. Tap **System \\\u003e About** or **System \\\u003e About \\\u003e Versions**.\n 2. Find the **Build number** item and tap it seven times. If your watch is protected by a PIN or pattern, enter it when prompted to do so.\n3. From the **Settings** menu, tap **Developer options**.\n4. Enable the **ADB debugging** option.\n\n### Connect watch to development machine\n\nSome watches let you connect over USB. Others require a wireless connection.\n\n#### Set up a wired connection over USB\n\nConnect the watch using the following steps:\n\n1. Using a USB cable, connect the watch to your development machine.\n2. On the watch, enable **Always allow from this computer** , and then tap **OK**.\n\n#### Set up a wireless connection\n\nIf your watch lacks a USB port, learn how to [connect a watch using Wi-Fi or\nBluetooth](/training/wearables/apps/debugging).\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 flash\na software image onto watches that support a USB (wired) data connection. For\nexample, you can flash a [factory image](https://developers.google.com/android/images-watch) or a [full OTA image](https://developers.google.com/android/ota-watch)\nonto a Google Pixel Watch 3 or Google Pixel Watch 2 device.\n\n### Open the app on the watch\n\n1. Go to **Run \\\u003e Select Device**. Choose the watch that is connected to your machine.\n2. In the Android Studio toolbar, click **Run** . The emulator starts and opens your app.\n3. After a few moments, you should see a \"Hello...\" message appear on the watch.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Integrate custom C/C++ build systems using Ninja (experimental)](/build/cxx-ninja)\n- [Vulkan validation layers on Android](/ndk/guides/graphics/validation-layer)\n- [Release notes](/training/wearables/versions/5/release-notes)"]]