Миграция в пространства имен ProtoLayout

Начиная с версии 1.2, большинство API макетов Tiles находятся в пространстве имен androidx.wear.protolayout . Чтобы использовать новейшие API, выполните следующие шаги миграции в своем коде.

Обновить зависимости

В файле сборки модуля приложения внесите следующие изменения:

классный

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

  // Include additional dependencies
  implementation "androidx.wear.protolayout:protolayout:1.2.0-rc01"
  implementation "androidx.wear.protolayout:protolayout-material:1.2.0-rc01"
  implementation "androidx.wear.protolayout:protolayout-expression:1.2.0-rc01"

  // Update
  implementation "androidx.wear.tiles:tiles:1.4.0-rc01"

Котлин

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

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

  // Update
  implementation("androidx.wear.tiles:tiles:1.4.0-rc01")

Обновить пространства имен

В файлах кода вашего приложения на основе Kotlin и Java внесите следующие обновления. Альтернативно вы можете выполнить этот скрипт переименования пространства имен .

  1. Замените весь импорт androidx.wear.tiles.material.* на androidx.wear.protolayout.material.* . Выполните этот шаг и для библиотеки androidx.wear.tiles.material.layouts .
  2. Замените большую часть импорта androidx.wear.tiles.* на androidx.wear.protolayout.* .

    Импорт для androidx.wear.tiles.EventBuilders , androidx.wear.tiles.RequestBuilders , androidx.wear.tiles.TileBuilders и androidx.wear.tiles.TileService должен остаться прежним.

  3. Переименуйте несколько устаревших методов классов TileService и TileBuilder:

    1. TileBuilders : getTimeline() для getTileTimeline() и setTimeline() для setTileTimeline()
    2. TileService : onResourcesRequest() до onTileResourcesRequest()
    3. RequestBuilders.TileRequest : getDeviceParameters() для getDeviceConfiguration() , setDeviceParameters() для setDeviceConfiguration() , getState() для getCurrentState() и setState() для setCurrentState()
{% дословно %} {% дословно %} {% дословно %} {% дословно %}