Wear OS apps run directly on a watch, giving you access to hardware such as sensors and the GPU. Wearable apps are similar to other apps that use the Android SDK, but differ in design and functionality.
A Wear OS app should work independently of a phone app, allowing users the greatest flexibility in their choice of phones.
- For more information, seeIndependent versus dependent Wear OS apps.
Note: You can test your app on an actual watch using USB, Wi-Fi, or Bluetooth as described inDebug a Wear OS app.
Debugging your app on an actual watch enables you to better evaluate the total user experience.
You can also use the watch emulator in Android Studio to test your app with different screen shapes and sizes.
- Install the latest version of Android Studio. For information about creating apps in Android Studio, see Projects overview.
- Use the SDK manager to confirm that you have the latest version of the Android platform that supports Wear OS, Android 11 (API level 30). If you plan to make your Wear OS apps available for China, see Create Wear OS apps for China. You can create a Wear OS app using Android Studio's New Project wizard. To create a project in Android Studio: . Click File > New > New Project. In the Project Template window, click the Wear OS tab, select Blank Activity, and click Next. In the New Project window, name your project, fill out the standard project information, and click Finish. Android Studio creates a project with an app module for your data provider. In the build.gradle file for the app module: In the android section, confirm that the compileSdkVersion is set to 28. In the android section, confirm that the targetSdkVersion is set to 28. Replace the dependencies section with Wear OS specific dependencies. In the android section, confirm that the compileSdkVersion is set to 28.
- Follow the steps to set up a phone.
On the phone, enable Developer Options and USB Debugging.
Connect the phone to your computer through USB.
Forward the AVD's communication port to the connected phone (each time the phone is connected):adb -d forward tcp:5601 tcp:5601.
On the phone, in the Wear OS app, begin the standard pairing process. For example, on the Welcome screen, tap the Set It Up button. Alternatively, if an existing watch already is paired, in the upper-left drop-down, tap Add a New Watch.
- app > java > com.example.myfirstapp > MainActivity
- This is the main activity. It's the entry point for your app. When you build and run your app, the system launches an instance of this
Activityand loads its layout.
- app > res > layout > activity_main.xml
- This XML file defines the layout for the activity's user interface (UI). It contains a
TextViewelement with the text "Hello, World!"
- app > manifests > AndroidManifest.xml
- The manifest file describes the fundamental characteristics of the app and defines each of its components.
- Gradle Scripts > build.gradle
- There are two files with this name: one for the project, "Project: My_First_App," and one for the app module, "Module: My_First_App.app." Each module has its own
build.gradlefile, but this project currently has just one module. Use each module's
build.gradlefile to control how the Gradle plugin builds your app. For more information about this file, see Configure your build.
On the phone, in the Wear OS app, tap the Overflow button, and then tap Pair with Emulator.