skip to Main Content

I use two different Systems for coding. At home, I have an iMac and while I am traveling or on business trips I have a Windows laptop. When working from home, I don’t have any problems running and developing my flutter app on both, iOS and Android.

However, when I am traveling I use my Windows Laptop I get weird errors from Firebase and my App seems to not like Firebase. I use Firebase Remote Config and Firebase Cloud Messaging.

When running my Android app on my Windows Laptop and try to get an FCM token, I get the following error:

E/FirebaseInstanceId( 4181): Failed to get FIS auth token
E/FirebaseInstanceId( 4181): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId( 4181):  at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.0.2:5)
E/FirebaseInstanceId( 4181):  at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.0.2:8)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.GmsRpc.setDefaultAttributesToBundle(com.google.firebase:firebase-iid@@21.1.0:11)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.GmsRpc.startRpc(com.google.firebase:firebase-iid@@21.1.0:1)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.GmsRpc.getToken(com.google.firebase:firebase-iid@@21.1.0:1)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$2$FirebaseInstanceId(com.google.firebase:firebase-iid@@21.1.0:1)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.FirebaseInstanceId$$Lambda$3.start(Unknown Source:10)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.RequestDeduplicator.getOrStartGetTokenRequest(com.google.firebase:firebase-iid@@21.1.0:7)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$3$FirebaseInstanceId(com.google.firebase:firebase-iid@@21.1.0:5)
E/FirebaseInstanceId( 4181):  at com.google.firebase.iid.FirebaseInstanceId$$Lambda$0.then(Unknown Source:6)
E/FirebaseInstanceId( 4181):  at com.google.android.gms.tasks.zze.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
E/FirebaseInstanceId( 4181):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/FirebaseInstanceId( 4181):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/FirebaseInstanceId( 4181):  at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.2.0:2)
E/FirebaseInstanceId( 4181):  at java.lang.Thread.run(Thread.java:1012)
E/FirebaseInstanceId( 4181): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseInstanceId( 4181):  at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:153)
E/FirebaseInstanceId( 4181):  at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:533)
E/FirebaseInstanceId( 4181):  at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:387)
E/FirebaseInstanceId( 4181):  at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3$com-google-firebase-installations-FirebaseInstallations(FirebaseInstallations.java:372)
E/FirebaseInstanceId( 4181):  at com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda0.run(Unknown Source:4)
E/FirebaseInstanceId( 4181):  at com.google.firebase.concurrent.SequentialExecutor$1.run(SequentialExecutor.java:117)
E/FirebaseInstanceId( 4181):  at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:229)
E/FirebaseInstanceId( 4181):  at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:174)
E/FirebaseInstanceId( 4181):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/FirebaseInstanceId( 4181):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/FirebaseInstanceId( 4181):  at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
E/FirebaseInstanceId( 4181):  at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(Unknown Source:4)

And this is the error I get for Firebase Remote config (also Android/Windows setup):

E/flutter ( 4181): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_remote_config/internal] internal remote config fetch error
E/flutter ( 4181): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter ( 4181): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter ( 4181): <asynchronous suspension>
E/flutter ( 4181): #2      MethodChannelFirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart:150:29)
E/flutter ( 4181): <asynchronous suspension>
E/flutter ( 4181): #3      FirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config/src/firebase_remote_config.dart:89:26)
E/flutter ( 4181): <asynchronous suspension>
E/flutter ( 4181): #4      BootService.initFirebase (package:myapp_app/services/boot_service.dart:32:5)
E/flutter ( 4181): <asynchronous suspension>
E/flutter ( 4181): #5      main (package:myapp_app/main.dart:16:3)
E/flutter ( 4181): <asynchronous suspension>

I also do have an old MacBook and tried to get my app to run on iOS to test whether it is a Windows/setup problem or if I can re-create the problem. There I get a totally other problem:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_remote_config/internal] Failed to get installations token. Error : Error Domain=com.firebase.installations Code=2 "Too many server requests." UserInfo={NSLocalizedFailureReason=Too many server requests.}.

When trying to print the FCM token with an Android device on my Mac I get the same error as on my Windows laptop with an Android device (see above).

This is my main.dart:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await BootService.initFirebase();
  ...
  ... 
  ...

 runApp(...)
}

And this is my boot_service.dart file:

class BootService {
  static initFirebase() async {
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );

    /// Remote Config
    final remoteConfig = FirebaseRemoteConfig.instance;
    await remoteConfig.setConfigSettings(RemoteConfigSettings(
      fetchTimeout: const Duration(minutes: 1),
      minimumFetchInterval: const Duration(hours: 1),
    ));
    
    await remoteConfig.setDefaults(ConfigFirebaseRemote.keyValuePairs);
    
    await remoteConfig.fetchAndActivate();
  }

  ...
  ...
  ...
}

I still don’t understand how it is possible that on my main setup (iMac) I can run both, Android and iOS without getting any errors… My google-services.json as well as my GoogleService-Info.plist are all correct set.

Inspired by this Stack answer, I also tested if my configuration works with the following CURL command. And yeah, it does work. I don’t get any error. It successfully authenticates.

api_key=<YOUR_API_KEY>
project_identifier=<YOUR_PROJECT_ID>
app_id=<YOUR_FIREBASE_APP_ID_EXAMPLE_1:12345678:android:00000aaaaaaaa>

curl -H "content-type: application/json" -d "{appId: '$app_id', sdkVersion: 't:1'}" https://firebaseinstallations.googleapis.com/v1/projects/$project_identifier/installations/?key=$api_key

My packages.yaml file:

environment:
  sdk: '>=3.3.1 <4.0.0'

firebase_messaging: ^14.7.20
firebase_core: ^2.27.1
firebase_remote_config: ^4.3.18

Here are my flutter doctor -v prints for all three of my machines.
Main Setup (iMac):

[✓] Flutter (Channel stable, 3.19.3, on macOS 14.4 23E214 darwin-arm64, locale de-DE)
    • Flutter version 3.19.3 on channel stable at /opt/homebrew/Caskroom/flutter/3.13.9/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (10 days ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/jantrier/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 77.1.3
    • Dart plugin version 232.10286

[✓] VS Code (version 1.87.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.4 23E214 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 122.0.6261.129

[✓] Network resources
    • All expected network resources are available.

Second Setup (Windows):

[√] Flutter (Channel stable, 3.19.3, on Microsoft Windows [Version 10.0.19045.4170], locale de-DE)
    • Flutter version 3.19.3 on channel stable at C:UsersUserDesktopflutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (11 days ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:UsersUserAppDataLocalAndroidsdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: C:Program FilesJavajdk-11.0.17binjava
    • Java version Java(TM) SE Runtime Environment 18.9 (build 11.0.17+10-LTS-269)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:Program FilesGoogleChromeApplicationchrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2023.2)
    • Android Studio at C:Program FilesAndroidAndroid Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[√] Network resources
    • All expected network resources are available.

My old MacBook:

[✓] Flutter (Channel stable, 3.19.3, on macOS 14.2.1 23C71 darwin-arm64, locale en-DE)
    • Flutter version 3.19.3 on channel stable at /Users/user/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (11 days ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/user/Library/Android/sdk
    • Platform android-34, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.87.2)
    • VS Code at /Users/user/Desktop/setups/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (2 available)
    • macOS (desktop)           • macos         • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)              • chrome        • web-javascript • Google Chrome 122.0.6261.129

[✓] Network resources
    • All expected network resources are available.

I have also tried to fix my Firebase Remote Config problem with the two following issues, but they did not work:

  1. https://github.com/firebase/flutterfire/issues/6196#issuecomment-887399471
  2. https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667

As mentioned from other users I also tried to set up a HotSpot and check date and time on my emulator. But those fixes also didn’t solve my problem…

I really don’t know what to do or try next to fix my problem. I cannot find any other Stack or GitHub issue which has faces the same or a similar issue. The most confusing part is that I have other apps which work very well with Firebase on my Windows Laptop and the app I am talking about in this post is working without any problem on my main setup…

I appreciate any kind of help!

2

Answers


  1. I am assuming here that there are no dev certificate file configured for Android and IOS for debug mode.

    So either you should add the SHA1 and SHA256 from your system to Firebase project [As no of system increases, it will be a huddle to maintain] or configure dev certificate for Android and IOS and then add the common SHA1 and SHA256 generated for the project on Firebase

    PS add both SHA1 and SHA256 to avoid any other issue

    Login or Signup to reply.
  2. i had this kind of issue with my windows and linux devices,

    created new app from widows made sure fresh app is running fine
    moved all myproject files to this new app (issued project configured in new app)
    then pushed to git, its was working fine in the other device as-well.

    I felt like wasted lot of time looking for a solution by thinking time and effort moving configuration to a new app .
    But it was quicker than finding a solution sitting on the same project .

    hope this helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search