Flutter web app paused at web_entrypoint.dart - firebase

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

Related

Expo - Firebase fails whenever ExpoGo is in Remote Debug mode

I'm facing a strange issue that I can't seem to figure out. Recently created a brand new project trying to do everything proper with Firebase v9 SDK. Building in Expo 45. All libraries latest. (Note, I have been building with similar stack for a while -- Expo + RN + Firebase)
Setting up new app scaffolding, everything is great. HOWEVER - when I use Expo Go and turn on remote debugging, it launches the debugger but immediately throws a bunch of Firebase errors:
If I goto the debug menu and turn off remote debugging, everything is fine. Anyone run into the same and have a solution?
Update:
I've isolated the issue to where I'm registering the onAuthStateChanged() event. In debug mode only, this code throws the errors:
export default function Navigation({ colorScheme }: { colorScheme: ColorSchemeName }) {
const [bUserAuthenticated, setUserAuthenticated] = useState<Boolean>(false)
useEffect(() => {
try {
const register = async () => {
const app = getApp()
const auth = await getAuth(app)
// const dispatch = useDispatch()
await auth.onAuthStateChanged((user) => {
if (user) {
setUserAuthenticated(true)
// loadUser()
} else {
setUserAuthenticated(false)
}
})
}
register()
} catch (err) {
console.error(`[Navigation.useEffect] ${err}`)
}
}, [])
Again, without running Expo Go in remote debug mode, this works fine. But when running in remote debug mode, it throws the Firebase unhandled promise exception errors.
It looks like there was an issue with the Firebase SDK version I was using (9.8.1). No matter what, whenever it was running in the RN debugger, when getting an instance of any of the modules, it would barf and give an error.
Downgrading to firebase 9.6.1 solved this issue.

flutterfire crashlytics not enable

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

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.

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 ^^

How to register for reCAPTCHA v3 site key for mobile app?

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await FirebaseAppCheck.instance.activate(webRecaptchaSiteKey: 'recaptcha-v3-site-key');
runApp(App());
}
I'm trying to upload a photo in Firebase Storage and it keeps running an error because of App Check. It says I need to configure it using the format above. How will I register my app for a recaptcha key?

Resources