升級到 Flutter 2.5 ...... 失敗怎麼辦?

紅寶鐵軌客
Join to follow...
Follow/Unfollow Writer: 紅寶鐵軌客
By following, you’ll receive notifications when this author publishes new articles.
Don't wait! Sign up to follow this writer.
WriterShelf is a privacy-oriented writing platform. Unleash the power of your voice. It's free!
Sign up. Join WriterShelf now! Already a member. Login to WriterShelf.
寫程式中、折磨中、享受中 ......
448   0  
·
2021/10/08
·
4 mins read


Flutter 在大約在三個禮拜前,發佈了 2.5 版的更新(我目前用的是 2.2.3),我對這種比較大的更新,都憂喜參半,喜的是一定有新功能或是 Bug 被移除了,憂的是通常會帶來新的問題,有時,甚至目前的程式還要做 Migration 搬遷。

What’s new in Flutter 2.5 — Performance improvements, DevTools updates, new Material You support, a new app template, and more!
Medium

如果是正式的開發案,我通常會先確定新版有我所需要的功能,或至少會等一兩個月後,才更新,簡單來說,如果沒有需要,目前日子過的好好的,為什麼要更新?但是我們現在是在「學習階段」,跟著新版本走,可以多玩多學並看看新東西,何樂而不為,反正我們的 App 又沒有上市期限,所以我就決定來試試新版 Flutter 了。

Flutter 2.5 簡介

Flutter 2.5 更新才短短兩個禮拜,就已經升級到 2.5.3 了,改版的真快,這是好事,代表有在除蟲,2.5 版有這些主要的新功能:

  • 支援 material v3
  • 多了 ScaffoldMessenger
  • DevTools 有新功能,主要是針對 frames 的效能監視
  • 新的 skeleton template:寫新 app 時,多了一個有多國語言與暗亮主題的 template 可選,不過說實話,我覺得我的寫法比較清楚好用。
  • 支援 Apple MacOS 用 M1 來開發。

也有些程式需要搬遷:

  • 原來使用 Flutter team plugins 的,都建議搬到 community plugins,還好我們目前都沒有用

看來,主要是效率變好,新功能倒是還好,至少不怎麼吸引我。


Flutter 2.5 升級步驟:
  • Xcode update to 13:剛好前幾天,Xcode 新版 13 發佈,我就決定更新它了,一次更新兩個平台絕對是錯誤,到時死在那裡都不知道,要步步為營,所以我是先更新 XCode,確定 Flutter 2.2.3 可以正常執行,才更新 Flutter 到 2.5。
    • 要確實的確定 Xcode 13 可在 Flutter 2.2.3 正常執行:安裝 Xcode 13 後,要重開機,確定 Flutter 2.2.3 及我們目前的開發中的 App 都可以正確地在 iOS/Android/Web 上面執行,很好,都正常。
  • 紀錄 Flutter 目前版本:
    • Terminal 執行:$ flutter --version,紀錄下來目前的版本資訊,以防萬一,如下:
      • Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
      • Framework • revision f4abaa0735 (3 個月前) • 2021-07-01 12:46:11 -0700
      • Engine • revision 241c87ad80
      • Tools • Dart 2.13.4
  • 先更新 AndroidStudio plugs,如果有需要更新,會顯示在 Event Log 中:
    • 我有 "Dart", "Kotlin", "Flutter" 需要更新,就按個 'Update all',就會自動更新了,很快就會被通知要重新啟動 AndroidStudio,重啟動後,Event Log 就會告訴你是不是已經跟新好了。
  • Flutter upgrade
    • 我是在下午 2:37 開始升級的,很簡單,打開 terminal,下指令:
      • $ Flutter upgrade
    • 然後就可以去泡茶聊天了,電腦開始 Upgrading Flutter to 2.5.2 from 2.2.3 in ......
    • 不到 3:00 就升級完成,好快,不用半小時,電腦顯示:
      • Flutter 2.5.2 • channel stable • ...... • Dart 2.14.3
      • 會自動執行 flutter doctor... 也都 ok,很棒,看來我多擔心了。
  • 再測試確認
    • App 在 Web / iOS 15 iphone 12 / Android Pixel3a API 30 x86 的模擬環境都再次確定執行正常,很好,看來,真的很順利。
  • 不幸,重開機後,App 不能在 iOS 模擬器上執行了:
    • 錯誤訊息:xcodebuild: WARNING: Using the first of multiple matching destinations ......
    • 一查網路,看來我並不孤單,連結在此,跟 Mobile FFMpeg 好像有關,但是這個 package 用的人非常多,應該不是它的問題。
    • 有可能是 Xcode 的問題,但是試了好多方法,如 reset Pod,Flutter clean 等等,都無解。
    • 看來最可能是 Flutter SDK 問題。
  • 退回 Flutter 2.2.3 版後,問題消失:
    • 在 terminal 中,執行:flutter downgrade
    • 電腦會問你:Downgrade flutter to version 2.2.3? [y|n],按 y 就退回 2.2.3 版了。
    • Downgrade 後,Flutter 也會自動執行 Flutter doctor,都 ok。
    • 再在 iOS 模擬器上測試 App,正確執行無誤。
    • 這也確定,就是 Flutter SDK 問題。


結論:

這次升級失敗, 看來 2.5.3 還是有些問題,至少有一些人跟我都遇到問題了,我會再等一下了,也許等到 2.6 以後了。


後記:

很快的就有能人異士解決了這個問題,基本上就是 Flutter 的問題,要在 iOS 上做個特殊的設定,連結在此,這就是一個典型的 SDK 升級造成的問題,當一個 SDK 越來越大時,測試是很難一次到位的,我不喜歡這個解法,決定跳過 2.5 等下一版。

2021/12/14:升級到 2.8 版,很順利、完全無痛,看來 Flutter 團隊有修正 2.5 版的這個錯誤了,很好,現在可以用 2.8 版了。




WriterShelf™ is a unique multiple pen name blogging and forum platform. Protect relationships and your privacy. Take your writing in new directions. ** Join WriterShelf**
WriterShelf™ is an open writing platform. The views, information and opinions in this article are those of the author.


Article info

This article is part of:
Categories:
Tags:
Date:
Published: 2021/10/08 - Updated: 2021/12/14
Total: 1180 words


Share this article:
About the Author

很久以前就是個「寫程式的」,其實,什麼程式都不熟⋯⋯
就,這會一點點,那會一點點⋯⋯




Join the discussion now!
Don't wait! Sign up to join the discussion.
WriterShelf is a privacy-oriented writing platform. Unleash the power of your voice. It's free!
Sign up. Join WriterShelf now! Already a member. Login to WriterShelf.