21

after updating Android Studio and flutter (and kotlin) i get this warnings/errors

how to solve or can i ignore without consequential error?

Thank you in anvance.

W/FlutterJNI(23046): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(23046): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(23046): FlutterJNI.init called more than once

Edit 23.03.2022:

it's because "await Firebase.initializeApp();" is called twice like in the documentation mentioned. i have to research more. maybe solution with firebase_options.dart.

enter image description here

Edit 16.04.2022:

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);

  // Set the background messaging handler early on, as a named top-level function
  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

  //String? token =
  await FirebaseMessaging.instance.getAPNSToken();
  await FirebaseMessaging.instance.getToken();
  //print('APNS token: $token');
}
AlexF1
  • 365
  • 3
  • 13
  • I had the same issue when I was trying some stuff out with firebase messaging. Unfortunately I couldnt find a fix and went back to flutter 2.8.1 :/ – Aknahseh_tg Mar 22 '22 at 11:46
  • if i remove all firebase lines from source code, the error is gone. i tried older versions of both plugins without success (firebase_messaging, firebase_core). – AlexF1 Mar 23 '22 at 19:09
  • the creation of the firebase_options.dart file didn't help. still the same error. https://stackoverflow.com/questions/70404936/missing-firebase-options-dart-file-in-course-get-to-know-firebase-for-flutter – AlexF1 Mar 28 '22 at 13:56
  • 1
    This message doesn't seem to cause any problem in the app. – Simpler Sep 28 '22 at 23:33
  • Hi, @AlexF1 do you found the solution for your issue? coz I'm facing the same like yours. mind to share your solution if you already solved it. Thanks. – MNFS May 02 '23 at 09:42
  • I didn't find a solution. This App project is canceled so I'm not looking for a solution anymore. – AlexF1 May 08 '23 at 18:48

1 Answers1

10

I was facing the same error. This message shows if you call FirebaseMessaging.instance multiple times. For Example:

    final _firebaseMessaging = FirebaseMessaging.instance
    await _firebaseMessaging.requestPermission(
      announcement: true,
      carPlay: true,
      criticalAlert: true,
    );
    await 
FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
      alert: true,
      badge: true,
      sound: true,
    );

So here, the FirebaseMessaging.instance is called twice. Solved by changing FirebaseMessaging.instance to _firebaseMessaging. Hope this might help.

Note: Do not use FirebaseMessaging.instance in differenta files, or use it by passing the initialized one.

pmatatias
  • 3,491
  • 3
  • 10
  • 30
Erin Rai
  • 101
  • 3