Google I/O 2021結束了, 都有什麼精彩內容呢?

Android部分的Playlist附上: Android & Play at Google I/O 2021

Developer Keynote (Google I/O '21)

對於Android的部分來說, 主要是:

Android 12

  • user safety.
  • performance; improved app startup; customizable launch animations.
  • user experience; widgets.

Create beautiful apps, easier

現代化的Android開發.

  • Android Studio的升級.
  • Kotlin: Kotlin Symbol Processing.
  • Jetpack: 各種libraries和Compose.

Build across screens.

  • 各種螢幕.
  • Voice.
  • Watches: Health services.

The top 3 things to know in Modern Android Development | Android @ Google I/O'21

Android開發的三個top topic:

  • Jetpack: 一系列的Jetpack libraries釋出了新版.

  • Tooling: Android Studio的升級, 有了WorkManager Inspector, UI的Inspector支援了View和Compose.
  • Kotlin.

What's new in Android | Keynote

Android 12 -> S.

  • @Deprecated -> deprecated.
  • Color.
  • Widgets.
  • Launch animations: 系統自帶啟動動畫, 可以定製.
  • Notifications: 新的template style; Trampoline(?) 優化點開notification的那個短暫延遲.
  • Toasts: 帶icon, 說明是哪個app彈的toasts; 控制個數.
  • Picture in Picture的改善.
  • ImageView有個setRenderEffect可以模糊照片了.
  • 可以用theme定製模糊.

  • list的彈力拉伸效果. (我自己起的名字, 其實人家叫stretch overscroll).
  • Graphics: AVIF. 可以過濾支援的media型別.
  • Privacy: 關於permission的一些改進; 剪貼簿內容會有toast說明來源; foreground restrictions.

What’s new in Android development tools | Session

Android Studio版本號設計.

  • Preview工具可以設定橫屏, 定製尺寸, 顯示blueprints, play animation. Compose的preview有互動模式.
  • Accessibility test framework scanner.
  • 適配多種螢幕: Layout validation.
  • 摺疊屏, 手錶.
  • 模擬器還可以模擬heart rate.
  • snapshots test.
  • WorkManager的tasks.
  • Migrate to Non-Transitive R Classes...

What’s new in Jetpack | Session

解釋了Jetpack的初衷和現狀.

alpha和beta版本的意思.

  • Experimental Annotations -> Stable.
  • CameraX -> Stable.
  • AppSearch -> Alpha.
  • DataStore -> 用來取代SharedPreferences.

  • Security Crypto -> Stable.
  • Hilt -> Stable.
  • WorkManager -> Stable. (Android Studio也推出了新的WorkManager Inspector.)
  • Room -> Stable.

  • ConstraintLayout -> Stable. MotionLayout + Motion Editor.
  • Fragment -> Stable.

    (詳見release notes: https://developer.android.com/jetpack/androidx/releases/fragment.)

    重建了FragmentManager; 新增了get result的callback; 廢棄了一些API, 並且Fragment StrictMode可以檢測專案中是否還在使用.
  • Navigation -> Alpha. 現在支援多個backstacks.
  • Google Shortcuts -> Alpha.
  • EmojiCompat -> Alpha. (AppCompat 1.4.0以後預設包含.)
  • Paging -> Stable.
  • Macrobenchmark -> Alpha. (app啟動和滾動效率; local/CI.)
  • Compose integrations.

What's new in Jetpack Compose | Session

為什麼我們需要一個全新的UI Toolkit呢. -> 為了適應更加現代化的開發方式.

faster & easier.

Compose將資料轉換成UI.

Checkbox的例子:



UI完全由引數控制. -> single source of truth. 沒有其他的狀態需要sync.

把引數和回撥提到方法引數中去:

  • You completely describe your UI for a given state.
  • The framework updates your UI when the state changes.

這裡有個圖, 推薦ViewModel暴露一個Screen狀態, 集中管理, 然後下發到每個composable.

這樣也利於測試.

Compose實現了material design, 提供了元件, 還有theming system.

有一個owl app的實現解說.

和傳統view的interop.

State of Kotlin on Android | Session

What’s new in Android Gradle plugin | Session

New APIs in the Android Gradle Plugin

Using Jetpack libraries in Compose | Session

Jetpack Compose和Jetpack中其他庫可以很好的結合使用.

Top 12 tips to get ready for Android 12 | Session

Getting Ready for Android 12.

  • Developer Options -> App Compatibility Changes.
  • Foreground services were designed for multi-tasking and completing a user action. -> 從後臺啟動foreground services將被限制.
  • Expedited Jobs with WorkManager APIs.
  • User may turn off the mic and camera sensors using mic and camera toggles.
  • Apps that have not been used for an extended period will be hibernated. (permissions, storage, services)
  • Nearby device permission. Decouple Bluetooth scanning from Location.
  • MAC address restriction.
  • Safe component exporting. 有intent filter就必須顯式宣告exported.
  • Custom notifications deprecation.
  • App link improvements.
  • WebView Samesite.
  • New stretch overscroll.