Migrate to ProtoLayout namespaces

As of version 1.2, most Tiles layout APIs are in the androidx.wear.protolayout namespace. To use the latest APIs, complete the following migration steps in your code.

Update dependencies

In your app module's build file, make the following changes:

Groovy

  // Remove
  implementation 'androidx.wear.tiles:tiles-material:version'

  // Include additional dependencies
  implementation "androidx.wear.protolayout:protolayout:1.3.0-alpha05"
  implementation "androidx.wear.protolayout:protolayout-material:1.3.0-alpha05"
  implementation "androidx.wear.protolayout:protolayout-expression:1.3.0-alpha05"

  // Update
  implementation "androidx.wear.tiles:tiles:1.5.0-alpha05"

Kotlin

  // Remove
  implementation("androidx.wear.tiles:tiles-material:version")

  // Include additional dependencies
  implementation("androidx.wear.protolayout:protolayout:1.3.0-alpha05")
  implementation("androidx.wear.protolayout:protolayout-material:1.3.0-alpha05")
  implementation("androidx.wear.protolayout:protolayout-expression:1.3.0-alpha05")

  // Update
  implementation("androidx.wear.tiles:tiles:1.5.0-alpha05")

Update namespaces

In your app's Kotlin- and Java-based code files, make the following updates. Alternatively, you can execute this namespace renaming script.

  1. Replace all androidx.wear.tiles.material.* imports with androidx.wear.protolayout.material.*. Complete this step for the androidx.wear.tiles.material.layouts library, too.
  2. Replace most other androidx.wear.tiles.* imports with androidx.wear.protolayout.*.

    Imports for androidx.wear.tiles.EventBuilders, androidx.wear.tiles.RequestBuilders, androidx.wear.tiles.TileBuilders, and androidx.wear.tiles.TileService should stay the same.

  3. Rename a few deprecated methods from TileService and TileBuilder classes:

    1. TileBuilders: getTimeline() to getTileTimeline(), and setTimeline() to setTileTimeline()
    2. TileService: onResourcesRequest() to onTileResourcesRequest()
    3. RequestBuilders.TileRequest: getDeviceParameters() to getDeviceConfiguration(), setDeviceParameters() to setDeviceConfiguration(), getState() to getCurrentState(), and setState() to setCurrentState()