Use Jetpack Compose on Wear OS

Using Jetpack Compose with Wear OS is similar to using Jetpack Compose for any other Android project. The main difference is that Jetpack Compose for Wear adds Wear-specific libraries that make it easier to create user interfaces tailored to watches. In some cases those components share the same name as their non-wear counterparts, such as androidx.wear.compose.material.Button and androidx.compose.material.Button.

Create a new app in Android Studio

To create a new project that includes Jetpack Compose, proceed as follows:

  1. If you’re in the Welcome to Android Studio window, click Start a new Android Studio project. If you already have an Android Studio project open, select File > New > Import Sample from the menu bar.
  2. Search for Compose for Wear and select Compose for Wear OS Starter.
  3. In the Configure your project window, do the following:
    1. Set the Application name.
    2. Choose the Project location for your sample.
  4. Click Finish.
  5. Verify that the project's build.gradle file is configured correctly, as described in Configure Gradle.

Now you're ready to start developing an app using Jetpack Compose. To learn more about Compose for Wear OS, see the Wear OS samples repository. To learn about Jetpack Compose for mobile check out the Compose pathway. Many of the development principles for Compose for mobile apply to Compose for Wear OS.

Jetpack Compose toolkit dependencies

To use Jetpack Compose with Wear OS, you’ll need to include Jetpack Compose toolkit dependencies in your app’s build.gradle file, as shown in the following snippet:

Groovy

dependencies {
    // General compose dependencies
    implementation "androidx.activity:activity-compose:1.3.1"
    implementation "androidx.compose.ui:ui-tooling-preview:1.0.3"
    // Other compose dependencies

    // Compose for Wear OS Dependencies
    implementation "androidx.wear.compose:compose-material:1.0.0-alpha07"

    // Foundation is additive, so you can use the mobile version in your Wear OS app.
    implementation "androidx.wear.compose:compose-foundation:1.0.0-alpha07"

    // If you are using Compose Navigation, use the Wear OS version (NOT THE MOBILE VERSION).
    // Uncomment the line below and update the version number.
    // implementation "androidx.wear.compose:compose-navigation:1.0.0-alpha07"

    // Testing
    testImplementation "junit:junit:4.13.2"
    androidTestImplementation "androidx.test.ext:junit:1.1.3"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.3"
    debugImplementation "androidx.compose.ui:ui-tooling:1.0.3"
}