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
// Removeimplementation 'androidx.wear.tiles:tiles-material:version'// Include additional dependencies implementation "androidx.wear.protolayout:protolayout:1.3.0-alpha01" implementation "androidx.wear.protolayout:protolayout-material:1.3.0-alpha01" implementation "androidx.wear.protolayout:protolayout-expression:1.3.0-alpha01" // Update implementation "androidx.wear.tiles:tiles:1.5.0-alpha01"
Kotlin
// Removeimplementation("androidx.wear.tiles:tiles-material:version")// Include additional dependencies implementation("androidx.wear.protolayout:protolayout:1.3.0-alpha01") implementation("androidx.wear.protolayout:protolayout-material:1.3.0-alpha01") implementation("androidx.wear.protolayout:protolayout-expression:1.3.0-alpha01") // Update implementation("androidx.wear.tiles:tiles:1.5.0-alpha01")
Update namespaces
In your app's Kotlin- and Java-based code files, make the following updates. Alternatively, you can execute this namespace renaming script.
- Replace all
androidx.wear.tiles.material.*
imports withandroidx.wear.protolayout.material.*
. Complete this step for theandroidx.wear.tiles.material.layouts
library, too. Replace most other
androidx.wear.tiles.*
imports withandroidx.wear.protolayout.*
.Imports for
androidx.wear.tiles.EventBuilders
,androidx.wear.tiles.RequestBuilders
,androidx.wear.tiles.TileBuilders
, andandroidx.wear.tiles.TileService
should stay the same.Rename a few deprecated methods from TileService and TileBuilder classes:
TileBuilders
:getTimeline()
togetTileTimeline()
, andsetTimeline()
tosetTileTimeline()
TileService
:onResourcesRequest()
toonTileResourcesRequest()
RequestBuilders.TileRequest
:getDeviceParameters()
togetDeviceConfiguration()
,setDeviceParameters()
tosetDeviceConfiguration()
,getState()
togetCurrentState()
, andsetState()
tosetCurrentState()
Recommended for you
- Note: link text is displayed when JavaScript is off
- Get started with tiles
- Create your first Tile in Wear OS
- Introduction to Compose for TV