Firebase Remote Config で FormatException: Invalid envelope のエラーが出る

Firebase Remote Config を Android で利用しようとしたら以下のようなエラーが出た。

I/flutter ( 6164): ----------------FIREBASE CRASHLYTICS----------------
I/flutter ( 6164): FormatException: Invalid envelope
I/flutter ( 6164): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:612:7)
I/flutter ( 6164): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
I/flutter ( 6164): <asynchronous suspension>
I/flutter ( 6164): #2      MethodChannelFirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart:147:29)
I/flutter ( 6164): <asynchronous suspension>
I/flutter ( 6164): #3      FirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config/src/firebase_remote_config.dart:87:26)
I/flutter ( 6164): <asynchronous suspension>
I/flutter ( 6164): ----------------------------------------------------

これはエラーメッセージが不親切で、message_codecs.dartデバッグコードを仕込んでみると以下のエラーが発生していることがわかる。

I/flutter (10863): Firebase Installations failed to get installation auth token for fetch.
I/flutter (10863): {code: internal, message: internal remote config fetch error}

というわけで、権限周りでエラーが発生していることがわかる。

解決策

解決策として、Android の keystore の SHA1/SHA256 を Firebase/GCP に登録すると解決する。

また、deploygate などを利用している場合は deploygate の SHA1/SHA256 を登録する必要がある。