firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

🐛 [firebase_messaging] com.google.firebase.installations.remote.FirebaseInstallationServiceClient.readGenerateAuthTokenResponse #9884

Closed grove86dipesh closed 10 months ago

grove86dipesh commented 2 years ago
Exception java.lang.AbstractMethodError: abstract method "androidx.fragment.app.A androidx.fragment.app.A.M(int)"
  at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.readGenerateAuthTokenResponse (FirebaseInstallationServiceClient.java:90)
  at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.b (FirebaseInstallationServiceClient.java:98)
  at com.google.firebase.installations.FirebaseInstallations.fetchAuthTokenFromServer (FirebaseInstallations.java:31)
  at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary (FirebaseInstallations.java:68)
  at com.google.firebase.installations.FirebaseInstallations$$InternalSyntheticLambda$2$0fe691881d3c6e3f9f35e0661a5b99403a594a708d00cac53574920400fd4f4a$0.run (FirebaseInstallations.java)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at java.lang.Thread.run (Thread.java:919)

I am facing the above issue on the live app.

pubspec.yaml :

firebase_core: ^2.1.0 firebase_messaging: ^14.0.2 firebase_analytics: ^10.0.2 firebase_crashlytics: ^3.0.2

/Users/dipeshjethva/flutter_sdk/flutter/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-x64, locale en-IN)
    • Flutter version 3.3.7 on channel stable at /Users/dipeshjethva/flutter_sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e99c9c7cd9 (7 days ago), 2022-11-01 16:59:00 -0700
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/dipeshjethva/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 31) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 107.0.5304.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Process finished with exit code 0

Screenshot 2022-11-09 at 12 35 18 PM
darshankawar commented 2 years ago

@grove86dipesh Are there any replicable steps you can provide or minimal code sample that we can use to verify this error ?

grove86dipesh commented 2 years ago

I submitted the app to the google play store everything was working fine but after a few weeks getting an app crash issue from firebase. In debug mode, we couldn't be facing any errors. this kind of error getting in the live version after some weeks.

My Main File Code :

Future<void> main() async {
  await runZonedGuarded(() async {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp(
        // options: DefaultFirebaseOptions.currentPlatform,
        );
    var _firebaseMessaging = FirebaseMessaging.instance;

    FlutterError.onError = (errorDetails) {
      // If you wish to record a "non-fatal" exception, please use `FirebaseCrashlytics.instance.recordFlutterError` instead
      FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails);
    };
    PlatformDispatcher.instance.onError = (error, stack) {
      // If you wish to record a "non-fatal" exception, please remove the "fatal" parameter
      FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
      return true;
    };

    // 3. On iOS, this helps to take the user permissions
    NotificationSettings settings = await _firebaseMessaging.requestPermission(
      alert: true,
      announcement: false,
      badge: true,
      carPlay: false,
      criticalAlert: false,
      provisional: false,
      sound: true,
    );

    if (settings.authorizationStatus == AuthorizationStatus.authorized) {
      String? deviceToken = await _firebaseMessaging.getToken();
      print("FirebaseMessaging token: $deviceToken");
    }

    // Set the background messaging handler early on, as a named top-level function
    FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
    FirebaseMessaging.onMessage.listen(_firebaseMessagingBackgroundHandler);

    if (!kIsWeb) {
      channel = const AndroidNotificationChannel(
        'high_importance_channel', // id
        'High Importance Notifications', // title
        description: 'This channel is used for important notifications.',
        // description
        importance: Importance.high,
      );

      flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

      /// Create an Android Notification Channel.
      ///
      /// We use this channel in the `AndroidManifest.xml` file to override the
      /// default FCM channel to enable heads up notifications.
      await flutterLocalNotificationsPlugin!
          .resolvePlatformSpecificImplementation<
              AndroidFlutterLocalNotificationsPlugin>()
          ?.createNotificationChannel(channel!);

      /// Update the iOS foreground notification presentation options to allow
      /// heads up notifications.
      await FirebaseMessaging.instance
          .setForegroundNotificationPresentationOptions(
        alert: true,
        badge: true,
        sound: true,
      );
    }

    final NotificationAppLaunchDetails? notificationAppLaunchDetails =
        !kIsWeb && Platform.isLinux
            ? null
            : await flutterLocalNotificationsPlugin
                ?.getNotificationAppLaunchDetails();
    if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) {
      print(
          'Giiv open with notification ${notificationAppLaunchDetails!.payload}');
      selectedNotificationPayload = notificationAppLaunchDetails.payload;
    }

    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
        .then((_) {
      runApp(Phoenix(child: GiivApp()));
    });
  }, (error, stackTrace) {
    FirebaseCrashlytics.instance.recordError(error, stackTrace);
  });
}
darshankawar commented 2 years ago

Thanks for the update. Using code sample above and running in debug and release mode, I am unable to replicate it. Based on the crash log, I am keeping this issue open for further insights from the team.

/cc @russellwheatley

russellwheatley commented 2 years ago

If you take a look at the error stack trace, it is coming entirely from the Firebase Installations package from the Firebase android SDK. I would suggest opening an issue on their repository to diagnose the issue.

ghost commented 2 years ago

https://github.com/firebase/firebase-android-sdk/issues/3507#issuecomment-1061372855

try this. adding proguard rules.

-keep class com.google.firebase.installations.** { *; }
-keep interface com.google.firebase.installations.** { *; }
russellwheatley commented 2 years ago

Thanks for the update, @ajdll5-dev 👍. Have you tried adding the above, @grove86dipesh?

google-oss-bot commented 1 year ago

Hey @grove86dipesh. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

grove86dipesh commented 1 year ago

I am continuously getting this kind of error on the google play console.I don't know why this issue is occurring from firebase.

Screenshot 2022-11-22 at 6 24 42 PM Screenshot 2022-11-22 at 6 25 15 PM
russellwheatley commented 1 year ago

@grove86dipesh did you read the above 2 messages?

utkudenis commented 1 year ago

Hi guys. We have same issues in our app when we updated our app to new version. Last version firebase Messaging package was 14.1.1 and new version of the app have 14.1.1 Last version of the flutter sdk was 3.3.8 new version of the app generated by using flutter sdk 3.3.10

We didn't have any problem like this before. We didn't update any code parts which is related to the firebase messaging service.

We don't specifiy any R8 related config in our code base. If User delete all app data manually, app is working fine.

Remmo commented 1 year ago

Hi guys. We have same issues in our app when we updated our app to new version. Last version firebase Messaging package was 14.1.1 and new version of the app have 14.1.1 Last version of the flutter sdk was 3.3.8 new version of the app generated by using flutter sdk 3.3.10

We didn't have any problem like this before. We didn't update any code parts which is related to the firebase messaging service.

We don't specifiy any R8 related config in our code base. If User delete all app data manually, app is working fine.

Same problem here, crash at every startup when app in downloaded from the store, once cleaned all app data manually it works.

Venusdjinni commented 1 year ago

Hello, I'm facing the same problem with an app in production. Even if i got crashlytics from users, I am not able to reproduce the issue with my phone and emulator. Any updates?

vixper commented 1 year ago

Hi, I've encountered the same problem on different apps. I found the problem is related to google backup encryption when updgarding after api 29. For me using:

firebase_core: ^1.4.0 firebase_messaging: ^11.2.6 firebase_crashlytics: ^2.8.1 dependency_overrides: firebase_core_platform_interface: 4.5.1

with compileSdkVersion 32

and adding:

android:allowBackup="false" android:fullBackupContent="false" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"

in AndroidMaifest.xml at application level, and then flutter clean, solved the issue.

Unfortunately, I'm unable to get it work with latest firebase packages and compileSdkVersion 33.

I wish it could help someone.

M1chlCZ commented 1 year ago

I am getting same problem, no of the findings are helping. It seems to be related to upgrade to Flutter 3.7 for me as it wasn't crashing prior to update.

vixper commented 1 year ago

I am getting same problem, no of the findings are helping. It seems to be related to upgrade to Flutter 3.7 for me as it wasn't crashing prior to update.

Have you tried my solution? I'm with flutter 3.7 too

M1chlCZ commented 1 year ago

I am getting same problem, no of the findings are helping. It seems to be related to upgrade to Flutter 3.7 for me as it wasn't crashing prior to update.

Have you tried my solution? I'm with flutter 3.7 too

Yes I did, it does not work for me, as I had these values there for other reasons already.

utkudenis commented 1 year ago

Hello, When I contacted firebase support, they asked me to download the firebase installation package and re-version and test it. When I asked if they were sure, they just returned as a suggestion. It is not clear that it will definitely solve the problem. Since we can't see the problem without uploading a new version to the play store, we can't test it either. Everything is ok with the downloads made via APK. We encounter this problem when the google play update is released via the bundle. I also opened a ticket to the play store, but I have no hope.

Venusdjinni commented 1 year ago

I just ended up rolling back my code to flutter 3.0.5 and everything started working again. I tried with v3.3.10 but no luck. Something else to note is that i confirm what @utkudenis said, that the problem occurs only when downloading from the play store.

M1chlCZ commented 1 year ago

Alright I fixed it, what you need to do is add proguard file for android, so here is content of the proguard-rules.pro (put it in the android > app)

-keep class com.google.firebase.installations.** { *; }
-dontwarn com.google.firebase.**
-keep class io.flutter.plugins.firebase.* { *; }
-keep interface com.google.firebase.installations.** {*;}

And then in in same folder edit gradle.build like this:

buildTypes {
        release {
            signingConfig signingConfigs.release
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
}

Done no crashes even on latest compileSDK, flutter version

utkudenis commented 1 year ago

Hi @M1chlCZ, What do you think about adding progurard-rules to flutter project? . Flutter does not use any proguard files in default. Did you test it play store production update ?

When we pulled the flutter version to 3.3.7 and downgraded the packages, we solved the problem for a short time, but now we can't trust and update any package. My doubt is whether this issue has anything to do with sentry. Braking changes were an update to a single sentry package. 6.16.0 to 6.18.3

I got a response from google play support about the source of this problem that they couldn't solve it and couldn't determine the cause.

edit : spelling

M1chlCZ commented 1 year ago

Hi @M1chlCZ, What do you think about adding progurard-rules to flutter project? . Flutter does not use any proguard files in default. Did you test it play store production update ?

When we pulled the flutter version to 3.3.7 and downloaded the packages, we solved the problem for a short time, but now we can't trust and update any package. My doubt is whether this issue has anything to do with sentry. Braking changes were an update to a single sentry package. 6.16.0 to 6.18.3

I got a response from google play support about the source of this problem that they couldn't solve it and couldn't determine the cause.

I am running it for around 10 days on Google Play and there is no longer any issues (if there would be a problems, it would now be in thousands), so I would say this fixed it. To be clear, I have never used proguard, it is just what i gathered on the internet. I've tried it out of the desperation and it worked.

utkudenis commented 1 year ago

If you add firebase_app_installation package to your project you can see the crash on the internal test :)

proguard file cannot solve my problem because live streaming and other features crashesh if ı use proguard settings

VB10 commented 1 year ago

Any updates on this? My app suddenly had a lot of crash in firebase...

`

firebase_core: ^2.11.0 firebase_dynamic_links: ^5.0.1 firebase_in_app_messaging: ^0.7.1+1 firebase_messaging: ^14.4.1 firebase_crashlytics: ^3.3.1 firebase_analytics: ^10.0.1 firebase_performance: ^0.9.1+1 `

subins829 commented 1 year ago

Hi guys.

We have same issues in our app when we updated our app to new version.

Last version firebase Messaging package was 14.1.1 and new version of the app have 14.1.1

Last version of the flutter sdk was 3.3.8 new version of the app generated by using flutter sdk 3.3.10

We didn't have any problem like this before. We didn't update any code parts which is related to the firebase messaging service.

We don't specifiy any R8 related config in our code base.

If User delete all app data manually, app is working fine.

any updates on this ?

VB10 commented 1 year ago

Any updates on this? My app suddenly had a lot of crash in firebase...

`

firebase_core: ^2.11.0 firebase_dynamic_links: ^5.0.1 firebase_in_app_messaging: ^0.7.1+1 firebase_messaging: ^14.4.1 firebase_crashlytics: ^3.3.1 firebase_analytics: ^10.0.1 firebase_performance: ^0.9.1+1 `

We fixed this issue by removing the BOM in the app's Gradle file. Maybe it will work for everyone.

tiancaidao commented 1 year ago

It's a problem with flutter + firebase + obfuscation, turn off proguard or disable obfuscation work for me.

ali-raza-flutter commented 1 year ago

I am having the same issue in my live and app is working fine on debug mode

here the logs i get from crashlytics

Fatal Exception: java.lang.AbstractMethodError: abstract method "b.a b.a.v(int)"
       at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.readGenerateAuthTokenResponse(FirebaseInstallationServiceClient.java:90)
       at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.b(FirebaseInstallationServiceClient.java:96)
       at com.google.firebase.installations.FirebaseInstallations.fetchAuthTokenFromServer(FirebaseInstallations.java:29)
       at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:68)
       at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3(FirebaseInstallations.java:68)
       at com.google.firebase.concurrent.SequentialExecutor$1.run(SequentialExecutor.java:2)
       at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:84)
       at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.run(SequentialExecutor.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
       at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0(CustomThreadFactory.java:13)
       at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:13)
       at java.lang.Thread.run(Thread.java:1012)
   My flutter sdk version is 3.13.3
   and 
  firebase_core: ^2.15.1
  firebase_crashlytics: ^3.3.5
  firebase_messaging: ^14.6.7
krupikivan commented 11 months ago

Any updates on this? Debug mode works fine but on live mode (from Play Store) not

russellwheatley commented 10 months ago

This issue isn't specific to FlutterFire, it seems possibly related to caching or obfuscation. Ultimately, the stack trace is clearly coming from Firebase android SDK. To summarise some of the fixes that have helped, folks, try the following:

  1. deleting app data on the device
  2. adding proguard rules to your build.gradle

FYI; This issue was opened on the Firebase android SDK and was resolved by the user using proguard config: https://github.com/firebase/firebase-android-sdk/issues/3507#issuecomment-1061372855