I have a flutter project with Android, iOS and Web platforms enabled, I'm using the following firebase plugins:
firebase_performance: ^0.8.2+1
firebase_database: ^9.0.20
cloud_firestore: ^3.4.1
firebase_core: ^1.20.0
All of them are added usgin FlutterFire. This is my main file:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
initializeDateFormatting('es');
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
.....
}
When i remove firebase_perfomance the app works fine, but when i add this plugin the app return the folliwing error message:
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.testapp.test_performance. Make sure to call FirebaseApp.initializeApp(Context) first.
I haven't google-services.json beacause I understand that it is not necessary if I use flutterfire
I run into same problem today :(
It's weird that seems Firebase App won't auto initialized before the flutter startup, if you setup the firebase plugin with flutterfire cli. And no one mentioned this problem.
Solution:
You can follow the https://firebase.google.com/docs/android/setup to setup the google services plugin,the firebase service seems would initialized to get the performance monitor works in early stage of APP.
I have the same issue with firebase_performance package. I solved the issue by running the following commands again.
dart pub global activate flutterfire_cli
flutterfire configure
Related
I'm receiving this error when try to initialize firebase on my flutter project
MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))
Someone have a clue about what I can do ?
App Gradle
Gradle plugins
Project Gradle
Flutter dependencies
I have setuped the firebase as the Google documentation
await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform);
Already tried on another simulator, already tried to create a fully new simulator, already tried on different devices, already tried with a specific's version of firebase, already tried to add
minifyEnabled false
shrinkResources false
to the gradle, but nothing works, already saw every video on the youtube about it,
The application throw this error for both platforms, android and iOS
i got this Error i didn't know how i would to solve it any solution Please.
when i initialise firebase im main function it show me this white screnn and flutter icon:
but when i delete this initliation this firebase app run successfully as it is:
and show me those errors
Make sure you have firebase_core in your pubspec.yaml
Then, just use the following in your main:
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
run
flutter clean
and
flutter pub get
in your terminal.
If it still fails, please go step by step following the firebase documentation. It should work. https://firebase.google.com/docs/flutter/setup?platform=android
I just forget to add Google services plugin in android/app/build.gradle:
apply plugin: 'com.google.gms.google-services'
How do I set flutter to work with firebase functions like firestore, storage, and authentication?
Firebase.initializeApp()
Your question is not clear but if you are asking how to add firebase dependencies; you can get packages from pub.dev.
And in any one of them; click the installing tab and use this code: flutter pub add xxx(depends on the package you use) for example for firebase auth:
flutter pub add firebase_auth
Do not add dependencies directly to pubspec.yaml because it will make some mismatch with other packages. when you use flutter pub add xxx you don't get any problem with the harmony of dependencies.
Addition:
If you're asking how to use Firebase.initializeApp() you need to call it where you will use Firebase. For example ;
Future<void> initializeDefault() async {
FirebaseApp app = await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
print('Initialized default app $app');
}
I'm working with Firebase in flutter (latest versions as of 1st July 2022), and when I try to call Firebase.initializeApp() in my Main function, it returns an error of:
'[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)'
Here is my code:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Firebase.initializeApp();
runApp(const MyApp());
}
Any help would be greatly appreciated
I was able to solve the problem by upgrading all my firebase dependencies to the latest version using flutter pub outdated and flutter pub upgrade firebase_....
I encountered this issue after adding the firebase_messaging plugin v11.4.4. Might be related to the change in firebase_core_platform_interface.
Also got it after a pub update. Fixed it by doing:
flutter clean
and removing the pubspec.lock
Do a flutter clean and upgrade firebase core with
flutter pub upgrade firebase_core
The run
dart pub global activate flutterfire_cli
flutterfire configure
to reinitialize firebase. I experienced this after adding app_check support
I have updated the below dependency:
dependency_overrides:
firebase_core_platform_interface: 4.4.1
Executed this command and updated firebase dependencies
flutter pub upgrade firebase_core
flutter pub upgrade firebase_messaging
it is working properly now.
Problem seems to be with the core platform interface.
Add firebase_core_platform_interface: 4.4.0 and adjust all other firebase deps to make them compatible with this library. I downgraded all versions to 36 day old release and it finally works.
I just built a new flutter app and I got this error when initializing Firebase App and running it in the browser and not the android emulator. I am using VS Code and you can change the target device in the bottom task bar on the right side.
Solution is to run it in the android emulator. I don't know if there are permissions to be set for web view but I do not plan on deploying to web.
Had the same problem and scaled back (thank you git) - getting flutter dependencies right - as in it compiles and work as advertised is no mean feat. Welcome :)
i am using geolocator in flutter project to get current location but this error come on it.
i added all dependencies in both ios and android files still get this error i dont know why
flutter channel stable, 2.12,
here is my code:
Position position = await Geolocato.getCurrentPosition( desiredAccuracy: LocationAccuracy.high);
here is my error coming which i tested android 10, 8 also, but answer same
Unhandled Exception: MissingPluginException(No implementation found for method getCurrentPosition on channel flutter.baseflow.com/geolocator)
i am using geolocator plugin here is plugin link :https://pub.dev/packages/geolocator
Maybe someone will need my solution. This happens because GeolocatorPlatform.instance is not initialized. Call _registerPlatformInstance() where you need.
import 'package:geolocator_android/geolocator_android.dart';
import 'package:geolocator_apple/geolocator_apple.dart';
void _registerPlatformInstance() {
if (Platform.isAndroid) {
GeolocatorAndroid.registerWith();
} else if (Platform.isIOS) {
GeolocatorApple.registerWith();
}
}
Running flutter clean and flutter pub get fixed the issue for me. I uninstalled the application, cleared the cache of my device and rebuilt the app. This time there was a popup asking to give location permission to the app.
I gave the access and got the current position of the device (latitude and longitude).
Also make sure you upgrade flutter to 3.0.0 by running flutter upgrade
If you just installed the package (geolocator), just restart the app or even better the phone.
Stop running the app completely and restart the app.
make sure that the app is killed before restart
click stop button, refer below,
Upgrade your flutter
Run on terminal flutter upgrade
or flutter upgrade —-force
Then =>flutter pub outdated
Then =>flutter pub upgrade
After that =>flutter pub upgrade —-major-versions
Finally go to
yourProjectName/android/app/build.gradle
Change:
android {
compileSdkVersion ##
…
…
}
To:
android {
compileSdkVersion 33
…
…
}