Google IO 2019 Android 太長不看版


Google I/O 2019, 這里有個playlist是所有Android開發相關的session視頻合集:
Android & Play at Google I/O 2019
當然啦每個視頻都看不太現實了, 就挑幾個看看吧.
這里是我個人的一點筆記, 可以作為一個太長不看版, 感興趣的點再自己了解下.

CameraX

  • 更易用的API.
  • 隱藏底層細節.
  • 兼容各種設備.
  • 自動化測試套件.

Android Studio UI design tools and Debugging Tools

Design Toolchain:

Layout Editor

  • Blueprint mode.
  • context menu來提供一些更方便的工作. constraint popup. constraint menu.
  • 預覽改進: RecyclerView的預覽改進. 預覽sample數據.
  • attribute界面可以指定dimen中定義的自定義尺寸.

相關文章:
https://medium.com/androiddevelopers/android-studio-project-marble-layout-editor-608b6704957a

  • navigation components的使用.
  • navigation editor中的預覽.

Resource Manager:

  • Batch Import, 可以直接把圖片資源拖拽整理進去. * 可以把svg拽進去變成vector drawable.
  • 提供了layout, color等的小圖預覽.
  • 顏色的alpha終於可以用百分比設置了.

Layout Inspector:

  • 改進了屬性顯示.
  • 可以直接預覽修改.
  • 3D顯示, 可以查找某個背景顏色到底是哪一層設置的.

(我的思考: 現在Android Studio越來越鼓勵開發者直接利用圖形界面來設置layout了, 總是喜歡直接編輯xml算不算是早期Android遺老遺少的一個陋習?)

What's New in Architecture Components

Kotlin first.

Data binding:

  • Faster complilation:
    android.databinding.incremental = true.
    增量注解處理.
  • 錯誤信息改善了. (耶!)

How to access views?

  • 幾種find view的方法比較.
  • View Binding: coming soon in Android Studio 3.6.

Lifecycle

  • ViewModel和Saved State.
    SavedStateHandle: 傳入ViewModel, 用於保存一些在應用被殺死后重啟仍然需要恢復的值.
  • 一些代碼的寫法被優化了.

WorkManager

優點: deferrable, persistent, constraint-based, backwards compatible.

  • 性能: on-demand initialization.
  • Google Play Services integration.
  • 兼容性.
  • 測試.
  • Future: foreground service.

Room

  • Coroutines, 協程支持: suspend方法.
  • Full text search: @Fts4, MATCH.
  • Database Views. @DatabaseView. 重新組織一個可查詢的數據結構, 類似於重新組裝一個表, 用來查詢.
  • 擴展了Rx支持: 數據庫操作方法可以返回Single, Completable等Rx類型.
  • Future: 注解處理; 關系改善; migration改善; 協程Channel&Flow.

Paging

What's next in Paging?

  • Built in network support with error handling.
  • Headers & footers
  • 更好的Rx和協程集成.
  • ViewModels scoped to Navigation Graphs.
  • Navigate by URI.
  • Dialog as destinations.
  • Safe Args.
  • Future: Better support for dynamic features.

最后廣告了一下這個課程:
https://www.udacity.com/course/developing-android-apps-with-kotlin--ud9012

What's New in Android

What's new in Android Q:

System UI

  • SAW: System Alert Window. -> 安全問題. -> 引入Bubbles (API 29).
  • Dark theme.
  • Share sheet: 內容預覽, 粘貼, 性能改善.
  • 通知分區域: Priority, Gentle.
  • Notification actions: 自動生成回復.
  • 手勢導航.

Platform

  • WebView: Trichrome: Separate WebView/Chrome, hung renderer檢測.
  • Accessibility.

Text

  • API 23默認開啟了連字符, 性能下降, 所以在Q默認關閉了.
  • API for fonts.
    還單獨有個text的演講專門講這個.

Magnifier

private APIs

要么用public的, 要么private改成public的, 要么加新的.
gray list中加了更多的(以后的版本將不能用了).

Android Runtime (ART)

Profile, 啟動改善, GC改善.

Kotlin

Q的新API有nullability注解.

Security

TLS 1.3 默認開啟.
生物識別改進.

Jetpack Compose

全新的UI組件: Kotlin, Reactive.
(很像Flutter.)

Privacy

  • 外部存儲限制.
  • Location: 權限設置更新. 新增只有前台時允許的選項.
  • 后台啟動Activity限制.

其他

  • CameraX
  • Architecture Components
  • ViewPager2
  • ViewBindings
  • Blend Modes
  • RenderNode
  • HardwareRenderer: 可以控制光源(陰影)
  • Hardware Bitmaps
  • Audio Playback Capture
  • 應用不能控制wifi開關
  • Settings Panel

Build a Modular Android App Architecture

為什么我們要模塊化呢?

  • scale: 更易分組開發人員; 更易查找資源.
  • 更快的編譯速度.
  • 更快的CI. 只執行有修改的module相關的測試.
  • Good for business. App Bundles: 更小的apk.
  • 分離的feature測試. 快速AB Test一個新功能.

兩種Modules:

  • Library Module
  • Dynamic Feature Module

如何分離模塊呢?

  • by feature
  • by layer
  • feature & layer.

模塊間的依賴

Module A依賴Module B:

  • api: Module B is part of my Public API. 依賴A的可以看到B.
  • implementation: Module B is my Implementation Detail. 依賴A的看不到B.

這里討論了一個分層模塊化構架中的問題: repo模塊對數據庫模塊的依賴, 用api, 上層可以直接使用數據庫模塊中的實例類, 但是同時暴露了DAO, 破壞了模塊化分離的意義.
兩個選擇:

  • 規定在上層不要操作數據庫.
  • 新建一個通用的數據模塊, 存放實體類, 數據庫模塊implementation依賴它, repo模塊api依賴它.

測試.

Dynamic feature modules

幾個挑戰:

  • 導航. 需要hardcode類名.
  • 找依賴. Dynamically loaded modules.

代碼例子: android-dynamic-code-loading
結合dagger.

數據庫

數據庫的幾種選擇:

  • 一個數據庫: 好維護, 好共享, 但是沒有分離.
  • 一個核心數據庫 + 每個feature自己的數據庫: 有了分離, 但是共享成了問題. 如果hybrid: 讓有交互的模塊共享, 也是挺復雜的.
  • 一個Room的bright feature: Multi-module數據庫. (Not Available now.)

最后閑聊了幾句關於構架的討論.
Android team只是提供options, 最后的選擇還是depends.

  • 考慮: short time costs, long time benefits.
  • 用戶不會因為app的構架好而給你5星.

What's New in the Android OS User Interface

三個方面:

  • Sharing: 性能改進; UI改進; 更多自定義選項.
  • Notifications: gentle; actions.
  • Multitasking: Bubbles.

Improving App Performance with Benchmarking

Jetpack Benchmark Library:
https://developer.android.com/studio/profile/benchmark.md

  • 可以測量工作方法的時間: 重復測量的Rule;
    合理排除初始化時間.
  • UI測試.
  • 新增module: Benchmark Module.

工具實現細節介紹.

Best Practices:

  • Start with tracing.
  • Synchronous blocks.
  • Small blocks
  • Hot code.
  • Caches.
  • @RunWith(Parameterized)
  • 不要比較設備.

例子: googlesamples/android-performance

最后, 歡迎關注微信公眾號: 聖騎士Wind
微信公眾號


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM