flutterfire crashlytics not enable - firebase

not enable crashlyrics in firebase console, after
await Firebase.initializeApp();
FirebaseCrashlytics.instance.crash();
my code
Future<void> main() async {
//runZonedGuarded<Future<void>>(() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
FirebaseCrashlytics.instance.crash();//this i also set in initState and build
runApp(const MyApp());
//}, (error, stack) => FirebaseCrashlytics.instance.recordError(error, stack));
}
app/build.gradle:
implementation platform('com.google.firebase:firebase-bom:29.0.4')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
android/build.gradle:
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
Tried start app with flutter run --release
also I tried use this example with my options: DefaultFirebaseOptions.currentPlatform: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart
I did everything according to the instructions from here https://firebase.flutter.dev/docs/ Getting started and Craslytics
don't have any errors, except for crashlytics not working in the firebase console

The problem was solved by another device, with android 11, with it there was a log about the request for crashlytics
There was no request on my device with 12 android, so far I will put the issue resolved, although I would like to have a solution to the problem for 12 android

Related

Facing 'No Firebase App has been created' while uploading to Firebase Storage in a Flutter app

I want to collect user browsing data for offline backend analysis for a Flutter app. What is the optimal way to do that?
What I am planning to do is run a daily cron on the app that uploads it using the WorkManager package.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
Workmanager().initialize(uploadUserData, isInDebugMode: true);
Workmanager()
.registerOneOffTask('1', 'task1', initialDelay: Duration(seconds: 10));
runApp(MyApp());
}
void uploadUserData() {
Workmanager().executeTask((task, inputData) {
firebase_storage.FirebaseStorage.instance
.ref('/uploads/test_workmanager.txt')
.putString('workmanager test');
return Future.value(true);
});
}
I am facing the following issue while running the above code
E/BackgroundWorker( 6733): errorCode: error, errorMessage: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
I/WM-WorkerWrapper( 6733): Worker result FAILURE for Work [ id=81642715-826f-4d40-b8ec-9d86eab75136, tags={ be.tramckrijte.workmanager.BackgroundWorker } ]
I have checked in multiple ways that firebase is initialized before calling the workmanager task (using firebase.apps.length & .whenComplete)
Update: Many are doubting whether firebase connection is right: basically everything just works if I just call firebase_storage....putString in the main() instead of within Workmanager().executeTask. So, the trouble is only due to Workmanager.
First call await Firebase.initializeApp(); in Workmanager().executeTask() async { }.
I recommend also "awaiting" all the following Firebase actions in the Workmanager task: await firebase_storage.FirebaseStorage.instance.[...]. This is because without await, the Workmanager might consider the task finished and kill the process before the Firebase action finishes.
Full Workmanager example task code with changes:
Workmanager().executeTask((task, inputData) async {
await Firebase.initializeApp();
await firebase_storage.FirebaseStorage.instance
.ref('/uploads/test_workmanager.txt')
.putString('workmanager test');
return Future.value(true);
});
You can call Firebase.initializeApp(); again in the Workmanager().executeTask() method before invoking any Firebase call.

Initializing Firebase Throws an Error - Flutter

While I was trying to set up Firebase, I learned that I need to initialize Firebase after the last updates. But when I run:
Firebase.initializeApp();
I get an error saying:
_CastError (Null check operator used on a null value)
I tried to remove it, afterwords everything worked fine.
This is the code I am running:
Future<void> main() async {
await Firebase.initializeApp();
runApp(SignIn());
}
According to documents this is how you can initialize firebase in your app:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(); //Make sure you imported firebase_core
runApp(SignIn());
);
}
Happy Fluttering :)

flutter firebase MissingPluginException

I just added firebase to my flutter App, i followed all the steps correctly, but i'm getting an error when initializing the app
this is my code to initialize app
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: new ThemeData(
canvasColor: Colors.white,
),
home: PersistentTabsDemo(),
onGenerateRoute: route.controller,
);
}
}
this are the dependecies i added to pubsec.yaml
firebase_core: ^1.6.0
firebase_analytics: ^8.3.1
firebase_auth: ^3.1.0
cloud_firestore: ^2.5.1
and this is the error
Error: MissingPluginException(No implementation found for method Firebase#initializeCore on channel
plugins.flutter.io/firebase_core)
Edit: i tried removing async and await from my main class now i'm getting new error
No firebase App 'default' has been created - call Firebase.intializeApp()
Try
Flutter clean
Pub.get
If these two doesn't work
Something is missing in setup of Firebase flutter
If anyone else had the same issue as me
I've fixed the issue by creating another project and added the sh1 and sh256 to firebase
just follow this tuto it's really helpful https://www.youtube.com/watch?v=CpyALC8Zpxo
PS: when u add firebase to your flutter project don't run it on chrome debug you will get an error, run it on your emulator or smartphone
happy coding ^^

Flutter web app paused at web_entrypoint.dart

I am new to flutter, I was trying to build a web app , and i am trying to save text data to firestore but whenever i run my web app it doesn't run and a new file is opened named web_entrypoint.dart and it hightlights this code
This is the highlighted code
i have already included firebase script to the html of web app
Here is the screenshot of vscode:
vs code screenshot
this is my main function
Future<void> main() async {
try {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
} catch (e) {
print('Failed to initialize');
}
runApp(MyApp());
}
Versions -
firebase_core: ^1.3.0
cloud_firestore: ^2.3.0
Dart: 2.13.4
The screenshot shows that your app paused at the breakpoint, you can just click on the Play button and the app should continue running as expected.
More reading: https://flutter.dev/docs/testing/debugging

not able to use firebase integration in flutter

I am using firebase in flutter application after updating the libraries to the latest version.
Below is the code which was previously used but now I am facing error
CODE
void main() {
FirebaseFirestore.instance.settings(timestampsInSnapshotsEnabled: true).then((_) {
print("Timestamps enabled in snapshots\n");
}, onError: (_) {
print("Error enabling timestamps in snapshots\n");
});
runApp(MyApp());
}
ERROR
error: The expression doesn't evaluate to a function, so it can't be invoked.
when I am implementing the above code I get the error, please help me to resolve this
Here's a code that should fix it.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
You need to Initialize the Firebase instance before runApp(MyApp());
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
//Before running App During load time initialize firebase instance.
runApp(MyApp());
}

Resources