AngeloAvv / flutter_flavorizr

A flutter utility to easily create flavors in your flutter application
https://pub.dev/packages/flutter_flavorizr
MIT License
468 stars 85 forks source link

Firebase Crashlytics just doesnt trigger errors #119

Closed Hamdan85 closed 2 years ago

Hamdan85 commented 2 years ago

Hey @AngeloAvv ,

I've researched a lot and didn't see anything about it so Im opening the issue.

I've deleted android and ios folder, then run flutter create -i swift -a kotlin ., then; run flutter pub run flutter_flavorizr

using this pubspec config:

flavorizr:
  ide: "vscode"
  flavors:
    dev:
      app:
        name: "App Name"
      android:
        applicationId: "com.example.appname"
        icon: "assets/icons/onemob-icon.png"
        firebase:
          config: ".firebase/development/google-services.json"
      ios:
        bundleId: "com.onemob.mobiledevelopment"
        icon: "assets/icons/onemob-icon.png"
        firebase:
          config: ".firebase/development/GoogleService-Info.plist"
    production:
      app:
        name: "App Name"
      android:
        applicationId: "com.example.appname"
        icon: "assets/icons/onemob-icon.png"
        firebase:
          config: ".firebase/production/google-services.json"
      ios:
        bundleId: "com.onemob.mobile"
        icon: "assets/icons/onemob-icon.png"
        firebase:
          config: ".firebase/production/GoogleService-Info.plist"

Then I run an exception but nothing is registered to crashlytics. I've checked (with breakpoints) and it seems that all is correctly set in the flutter part... correct firebase settings. But for some reason, no crashs are reported on firebase.

Do you have any idea of what might be happening?

Also, should I run flutterfire?? I did before but I think it got pretty messy and I've decided to start over, as I said, by cleaning everything.

bhavin-concetto commented 2 years ago

@Hamdan85 Have you got any solution?

Hamdan85 commented 2 years ago

@bhavin-concetto user runZonedGuarded:

void main() async {
  runZonedGuarded<Future<void>>(() async {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();

    FlutterError.onError =
       FirebaseCrashlytics.instance.recordFlutterFatalError;

    runApp(MyApp());
  }, (error, stack) =>
    FirebaseCrashlytics.instance.recordError(error, stack, fatal: true));
}

from docs: https://firebase.google.com/docs/crashlytics/get-started?platform=flutter

AngeloAvv commented 2 years ago

Hey @Hamdan85 , did you solve your issue?

AngeloAvv commented 2 years ago

For the upcoming people that are going to face this problem in the next future: flutter_flavorizr doesn't know if you are using crashlytics in your Firebase configuration, that's why you should stick to the Firebase docs after the flavorizer prepared the environment.

So putting additional code in the main file is mandatory and it could be the main reason why things are not working

Hamdan85 commented 2 years ago

@AngeloAvv yeah...it wasn't flavorizr fault. Two things happened that made me think that it was:

  1. I'm new at flutter development and I wasn't introduced at runZonedGuarded so I didn't know that I should be using it as default.
  2. It was a memory issue. I was recording a video in Highest quality and then trying to trim it using ffmpeg, which consumes lots of memory. It seems that iOS has something that kills high memory consuming apps without any notice. When this happens no crash are logged. I've lowered the quality and the issue was gone.
Hamdan85 commented 2 years ago

@AngeloAvv I must add that flutter_flavorizr is an amazing package and helped me a lot. Thank you sir!