Flutter2.10のプロジェクトを引き継いでリリースするまでにやったこと(Android)
実運用されている、1年以上アップデートのなかったアプリの開発を引き継ぐことがありました。
ローカル環境で動作させ、アップデートをリリースするまでに必要だったことを書きました。
Google Play Consoleのデベロッパーアカウント停止の警告が来ており、数日以内に対応する必要があったので大変でした。
このこともあり今回はAndroidに限って書いています。
引き継いだ時点での諸々のバージョン(今回変更したものだけ)
- Flutter 2.10.5
- Kotlin 1.3.50
- compileSdkVersion, targetSdkVersion 33
- Android Gradle Plugin 3.5.4
ローカル環境で動かすまで
GradleとJavaのバージョンを合わせる
アプリケーションを起動させようとすると以下のエラーが出ました。
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67
ローカルに入っているopenjdkのバージョンは23.0.1
でした。
使用しているGradleのバージョンは6.3
で、java23に対応していないためのエラーでした。
javaのバージョンを11系に落として対応しました。
No named parameter with the name 'autovalidate'.
datetime_picker_formfieldというライブラリで以下のエラーが出ました。
: Error: No named parameter with the name 'autovalidate'.
datetime_picker_formfield.dart:68
autovalidate: autovalidate,
^^^^^^^^^^^^
バージョンは1.0.0
を使用。
原因はFlutterv2.5でautovalidate
という引数がautovalidateMode
に変更されていて使えないため。
参考: https://docs.flutter.dev/release/breaking-changes/2-5-deprecations
datetime_picker_formfieldのv2を試してみたところ別のエラーが出た、かつ、
プロダクトでautovalidate
を使っていなかった、さらにdatetime_picker_formfieldの実装が1ファイルだけだったので以下のように対応しました。
-
ライブラリの実装ファイルをまるっとコピーして
lib/vendor/datetime_picker/form_field.dart
というファイルを作成 -
autovalidate
の箇所をautovalidateMode
に修正 - datetime_picker_formfieldライブラリを削除
- datetime_picker_formfieldライブラリを使用していた箇所を
lib/vendor/datetime_picker/form_field.dart
を使用するように変更
The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'
photo_viewというライブラリで以下ののエラーが出ました。
: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
photo_view_gesture_detector.dart:106
- 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../../fvm/versions/2.10.5/packages/flutter/lib/src/gestures/events.dart').
- 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../../fvm/versions/2.10.5/packages/flutter/lib/src/gestures/events.dart').
events.dart:1
super.addAllowedPointer(event);
^
3
FAILURE: Build failed with an exception.
この時のphoto_viewのバージョンは0.11.1
0.12.0
にすることで対応しました。
This app is using a deprecated version of the Android embedding.
以下のエラー(Warningだがビルドに失敗する)が出ました。
Running "flutter pub get" in flutter_tools... 11.4s
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at
https://flutter.dev/go/android-project-migration
to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
省略
Running "flutter pub get" in ... 41.6s
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
The plugin `cloud_firestore` requires your app to be migrated to the Android embedding v2. Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command.
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects に
アクセスしてさらにhttps://github.com/flutter/flutter/blob/master/docs/platforms/android/Upgrading-pre-1.12-Android-projects.mdへ遷移すると対応方法が書かれています。
以下の対応がまだされていなかったので対応しました。
- android:name="io.flutter.app.FlutterApplication"
+ android:name="${applicationName}"
Kotlinバージョンアップ
Your project requires a newer version of the Kotlin Gradle plugin.
というエラーが出ました。
1.5.31
となっています。
1.3.50
を使用していたので1.5.31
にあげました。
buildscript {
ext.kotlin_version = '1.5.31'
FVM3系対応
動かすために必須というわけではなかったですが。
自分の手元ではFVMを初めて使うのでinstallしたらFVM3系がinstallされました。
なのでついでにFVM3系の構成の変更しました。
変更点は以下。
.fvm
ディレクトリをgit管理から外す
Starting with version 3.0 and above, it is recommended to add the .fvm directory to your .gitignore file.
https://fvm.app/documentation/getting-started/configuration
.fvmrc
の新規追加
{
"flutter": "2.10.5",
"flavors": {}
}
リリース
鍵の再発行
開発の前任の方が鍵を紛失していたので、再発行をしました。
ローカルで鍵を用意し、Google Play Consoleでアップロード鍵のリセットのリクエストをしました。
リクエストすると新しい鍵が有効になるまで48時間待つ必要があり、その間はアプリのリリースや内部テスト用のaabのアップロードもできませんでした。
48時間後に無事有効になっていました。
Android 14対応
2024 年 8 月 31 日以降:
新しいアプリとアプリ アップデートを Google Play に送信する場合は、Android 14(API レベル 34)を対象にする必要があります(Wear OS アプリと Android TV アプリは Android 13 以降を対象にする必要があります)。
https://support.google.com/googleplay/android-developer/answer/11926878?hl=ja
こちらの対応が必要だったので対応しました。
android {
compileSdkVersion 34
省略
defaultConfig {
targetSdkVersion 34
省略
}
compileSdkVersionとtargetSdkVersionが33
だったのを34
に変更しました。
SDKのバージョンを上げると以下のエラーでビルドできなくなりました。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processStagingDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-3.5.4-6197926-osx Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
* 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 16s
Running Gradle task 'assembleStagingDebug'... 19.4s
Exception: Gradle task assembleStagingDebug failed with exit code 1
Gradleプラグインのバージョンを投稿にある通り3.5.4
から7.1.2
に上げるとエラーが発生しなくなったので、Gradleプラグインのバージョンを上げることで対応しました。
Discussion