It takes a lot of time for flutter app loading - flutter

It takes a lot of time app loading for second app starting not first app start.
Two points have consumed long time ( almost 1 min )
[+29806 ms] DevFS: Creating new filesystem on the device (null)
type here
[+29848 ms] I/FLTFireMsgService( 7408): FlutterFirebaseMessagingBackgroundService started!
my stack is like following.
firebase_core: ^2.3.0
firebase_crashlytics: ^3.0.10
firebase_messaging: ^14.1.2
flutter local notification : 12.0.4
if you have any solution, would you like to share the solution for this ?

Related

Firebase deployed flutter web page throws exception (since today) - why?

I have a flutter web app with the following dependencies, updated today to most recent ones. There was no code change! Just version updates:
firebase_storage: ^11.0.12
firebase_core: ^2.6.0
cloud_firestore: ^4.4.1
firebase_auth: ^4.2.7
Running the web app locally works fine (Chrome), but when I upload/deploy it to firebase, I get the following Exception:
VM155:2 Uncaught (in promise) TypeError: Failed to resolve module specifier 'Instance of 'TrustedScriptURL''
at window.ff_trigger_firebase_core (<anonymous>:2:18)
at mJ.v7 (main.dart.js:49235:19)
at main.dart.js:52258:9
at aJx.a (main.dart.js:6218:62)
at aJx.$2 (main.dart.js:45146:14)
at Object.M (main.dart.js:6204:10)
at ag6.aqG (main.dart.js:52262:10)
at ag6.BK (main.dart.js:52239:21)
at ag8.$1 (main.dart.js:52332:15)
at e9.q (main.dart.js:44287:19)
which is this statement
and the same exceptions for all other firebase packages:
The problem is, when I now revert back to the old firebase version, the problem stays! I don´t know what happened. Edge browser shows the same exception.
Thanks!

MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) in flutter

Both IOS and Android build was working fine. But recently when I tried to run my app in IOS device I got this error and the screen keeps loading in splash screen.
I tried multiple ways like,
flutter clean
flutter pub get
deleting pubspec.lock file
deleting podfile.lock file
nothing solved my issue.
But when I tried this method,
SharedPreferences.setMockInitialValues({});
The app will run in ios, but when we kill the app and open it again all the values stored in shared preferences will be null.
You can try these steps:
flutter clean
flutter pub get
Invalid Caches and Restart

Firebase background message handler in flutter spawns duplicate isolate and runs the app twice

I have below packages in my pubspec.yaml
firebase_core: ^2.2.0
firebase_messaging: ^14.1.0
And in my main.dart
#pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
}
void main() {
WidgetsFlutterBinding.ensureInitialized();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(const MyApp());
}
This causes my main method to run twice, in 2 isolates. If I remove the FirebaseMessaging.onBackgroundMessage(...) line, it runs a single isolate.
I see this in vscode callstacks window when I put a break point at runApp(...) as this gets hit twice.
Without onBackgroundMessage line
With onBackgroundMessage line
As a result of this, the firebase onMessage and other handlers fire twice for each notification and does duplicate work, and since they're in different isolates, its hard to check and avoid it. (example above does not have this part)
I see the build method for MyApp also runs twice, which I don't want. This likely has a memory and compute cost which I would like to avoid.
I would like to know if this is normal behavior? If so, is there a way to avoid this? i.e is there a way to detect the duplicate isolate and main method can return?
If its not normal behavior, what am I doing wrong?
for completeness, output of flutter --version
Flutter 3.3.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 6928314d50 (3 weeks ago) • 2022-10-25 16:34:41 -0400
Engine • revision 3ad69d7be3
Tools • Dart 2.18.2 • DevTools 2.15.0
UPDATE:
Below latest versions now work as expected.
firebase_core: 2.3.0
firebase_remote_config: 3.0.6
firebase_analytics: 10.0.6
firebase_crashlytics: 3.0.6
firebase_messaging: 14.1.1
Firebase team has reverted some changes and will apply it in a future version.
If you're only using messaging, use the following versions
firebase_core: ^1.24.0
firebase_messaging: ^13.1.0
If you're using other firebase services, these are the versions I managed to get to work together, without using dependency overrides.
# when you update firebase versions again because its
# "good practice" and it ended up in subtle bugs, loss
# of self-confidence, sleep deprevation and an overall
# degredation in quality of life, increase the counter
# here as a warning for the time after that you feel
# like doing it again.
#
# time spent resolving issues caused by updating
# firebase version upgrades that wasn't needed: 43h
# versions last updated on: 15 nov 2022
firebase_core: 1.24.0
firebase_remote_config: 2.0.20
firebase_analytics: 9.3.8
firebase_crashlytics: 2.9.0
firebase_messaging: 13.1.0
Currently you can either take the latest versions of everything and accept the bug, or lock your firebase packages to above versions and wait for a time you have a good weekend free to try and update to the latest versions and see what breaks.
It will likely be fixed eventually, and will likely be delivered in a bugfix version to all the packages.
Got pointers from this question and answers
This issue on github is likely the same as this one.

Calling Firebase.initializeApp() returns 'Unable to establish connection on channel' - Flutter + Firebase

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 :)

How to solve 'could not find package integration_test in the Flutter SDK' error

I have an app, it is very simple and I keep getting this error:
pub get failed (server unavailable) -- attempting retry 1 in 1
second... Because bascis depends on integration_test any from sdk
which doesn't exist (could not find package integration_test in the
Flutter SDK), version solving failed.
I have tried
Pup upgrade, Pub get.
How can I get rid of this error?
I had the same error after changing my channel from master to stable. I was able to fix it by removing (or commenting out) the following library from pubspec.yaml
dev_dependencies:
# integration_test:
# sdk: flutter
I experienced this when I was trying to setup a flutter web project without enabling flutter web on my PC. I enabled flutter for web and everything was okay.
For me had to comment out sdk part like so:
dev_dependencies:
integration_test:
# sdk: flutter
It is likely due to your network problem. Because the output says (server unavailable).
Ways to debug this:
Try curl https://google.com to see whether your command line can connect to network.
Also try, for example, curl https://flutter.dev (or, try to curl the actual url your pub get is trying to access.
This may due to, for example, your network is broken. Or because you have a broken VPN, broken proxy, etc.