Flutter3にアップグレードしたのでリリース済みの3アプリをバージョンアップしました。
色々罠があったので備忘録を残します。
横浜市立図書館利用状況アプリ
パッケージをアップグレード
flutter_webview_pluginがAndroid embeddingの非推奨バージョンを使っているという警告。
いつも出るので一旦スルーします。問題なく完了。
%flutter pub upgrade
15 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
The plugin `flutter_webview_plugin` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a
future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
アプリをビルド
Null Safety非対応の「flappy_search_bar」を使っているため「–no-sound-null-safety」をつけています。無事起動はしたので動作確認を行っていきます。
yokohama_city_library % flutter clean
yokohama_city_library % flutter run --no-sound-null-safety
Running "flutter pub get" in yokohama_city_library... 1,367ms
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Launching lib/main.dart on iPhone 13 mini in debug mode...
Running pod install... 1,597ms
Running Xcode build...
└─Compiling, linking and signing... 4.3s
Xcode build done. 19.6s
flutter: call fetchApiResults
Syncing files to device iPhone 13 mini... 142ms
以下は発生したエラーです。
Flutter2では問題なかったのでFlutter3による影響かと思います。
flappy_search_barで古いAPIを使っていることによるエラー
「貸出履歴」の検索でエラーがでています。
色々調べたところ上記「flappy_search_bar」の中で古いAPIを呼んでおり、そこでEXCEPTIONが発生しているらしいことがわかりました。
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building NotificationListener<KeepAliveNotification>:
RenderObjectElement.insertChildRenderObject() is deprecated.
insertChildRenderObject() was called on this Element: SliverStaggeredGrid:
delegate: SliverChildBuilderDelegate#ce46d(estimated child count: 1)
renderObject: RenderSliverStaggeredGrid#cc015 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT
insertChildRenderObject() has been deprecated in favor of insertRenderObjectChild(). See
(Insert|Move|Remove)ChildRenderObject methods lack parity · Issue #63269 · flutter/flutterProblem Statement Currently, these methods have the following signatures: void insertChildRenderObject(covariant RenderObject child, covariant dynamic slot); vo... for details.
Rather than overriding insertChildRenderObject() in your RenderObjectElement subclass, override
insertRenderObjectChild() instead, and DON'T call super.insertRenderObjectChild(). If you're
implementing a new RenderObjectElement, you should override/implement insertRenderObjectChild(),
moveRenderObjectChild(), and removeRenderObjectChild().
代替のパッケージを探したところ「flappy_search_bar_ns」なるものがあったので、試しにこれに差し替えてみたらエラーが解消しました。
ついでにNull Safety対応もされているので、ビルド時のオプションも不要となりました(喜)
ちなみに「flappy_search_bar_fork」というのもありましたが、こちらは Null Safety対応されていないので使いませんでした。
flutter_webview_pluginのonStateChangedが完了しない
flutter_webview_pluginのonStateChangedがWebViewState.shouldStartを発火して以降、いつまでたっても次のStateが発火しなくなっていることがわかりました。
冒頭にも記載した通り、「flutter_webview_plugin」は 非推奨バージョンの警告が出ており、パッケージのページでは、公式の「webview_flutter」に移行していく旨が書いてあるので、このタイミングで移行することにしました。
「webview_flutter」にも必要なものは揃っていたので、特に問題なく移行して無事動くようになりました。
リリース完了!
横浜市立図書館利用状況〜ブラウザ不要&自動ログインで簡単管理
無料posted withアプリーチ
来期アニメ
以下の記事で実施済み。
リリース完了!
来期アニメ-「来期のアニメ何観よう」を解決!
無料posted withアプリーチ
弱点スクラップノート
パッケージをアップグレード
問題なく完了
% flutter pub upgrade
〜
26 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
アプリをビルド
無事起動はしたので動作確認を行っていきます。
scrapbook % flutter clean
scrapbook % flutter run
Running "flutter pub get" in scrapbook... 2,455ms
Launching lib/main.dart on iPhone 13 mini in debug mode...
以下は発生したエラーです。
Flutter2では問題なかったのでFlutter3による影響かと思います。
flare_flutterで実行時にWarning
3つとも「flare_flutter-3.0.2/lib/flare_render_box.dart」です。
メッセージ見る感じではNull Safety対応が適切にされていない感じのように見えます。
flare_flutterを入れた覚えはないですが何かのパッケージの依存関係で入ったのですかね。
軽くググると、既知の問題なので無視しておk、的な感じだったので、Warningであること、パッケージのため手を出せないことも踏まえ、一旦放置することにしました。
../../../.pub-cache/hosted/pub.dartlang.org/flare_flutter-3.0.2/lib/flare_render_box.dart:167:26: Warning: Operand of null-aware operation '?.' has type
'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance?.cancelFrameCallbackWithId(_frameCallbackID);
^
../../../.pub-cache/hosted/pub.dartlang.org/flare_flutter-3.0.2/lib/flare_render_box.dart:170:28: Warning: Operand of null-aware operation '?.' has type
'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance?.scheduleFrameCallback(_beginFrame) ?? -1;
^
../../../.pub-cache/hosted/pub.dartlang.org/flare_flutter-3.0.2/lib/flare_render_box.dart:272:26: Warning: Operand of null-aware operation '?.' has type
'SchedulerBinding' which excludes null.
- 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
SchedulerBinding.instance?.cancelFrameCallbackWithId(_frameCallbackID);
^
image_picker_androidでリリースビルド時にError
デバッグビルドで問題ありませんでしたがリリースビルドでErrorがでました。
image_picker_androidは、image_pickerの依存パッケージらしく、そこでエラーが出てアプリを起動できません。
‘:app:lintVitalRelease’を見る限り、javaのlintでコケてる感じ?
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':image_picker_android:debugUnitTestRuntimeClasspath'.
> Failed to transform bcprov-jdk15on-1.68.jar (org.bouncycastle:bcprov-jdk15on:1.68) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: /Users/user/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar.
> Failed to transform '/Users/user/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk15on/1.68/46a080368d38b428d237a59458f9bc915222894d/bcprov-jdk15on-1.68.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8m 37s
とりあえずエラーメッセージでググってみると、それっぽい解決法がstackoverflowで2つ見つかりました。
1つ目は恐らくlintOptionsでエラーを黙らせるパターン?
2つ目は、恐らくエラーがでないimage_picker_androidのバージョンで上書きするパターン?
0.8.5以上のバージョンを指定するとダメっぽくて、0.8.4+13のピンポイント指定の必要があるようです。
どっちのパターンもOKでした。
image_picker_androidの最新バージョンでいずれ解決されることを期待して2つ目を採用しました。
無事アプリを起動できて一通りの動作確認してみましたが特に問題はありませんでした。
リリース完了!
弱点スクラップノート-間違った問題をできるまで解き直し勉強!
無料posted withアプリーチ
コメント