adjust / flutter_sdk

This is the Flutter SDK of
MIT License
59 stars 49 forks source link

Adjust not initialized, can't perform onResume #116

Closed LegendGin closed 1 month ago

LegendGin commented 1 year ago

I launch the flutter sample application, and get "Adjust not initialized, can't perform onResume" warning in logcat, does this warning matter?

monisnap-jeremie commented 1 month ago

Do you mean that you have an error like mine?

case AppLifecycleState.resumed:
  Adjust.onResume();
  break;
The member 'onResume' can only be used within 'package:adjust_sdk/adjust.dart' or a test.dart[invalid_use_of_visible_for_testing_member](https://dart.dev/diagnostics/invalid_use_of_visible_for_testing_member)
uerceg commented 1 month ago

Hey guys,

Have you upgraded your SDK to v5? If yes, there's no need to make calls to Adjust.onResume() and Adjust.onPause() on your own anymore since native Android SDK has now been made to handle those things automatically.

monisnap-jeremie commented 1 month ago

Hey @uerceg,

Thanks for your answer.

Yes, I have just upgrade adjust_sdk flutter package to v5 and have the following error:

The member 'onResume' can only be used within 'package:adjust_sdk/adjust.dart' or a test.dart[invalid_use_of_visible_for_testing_member](https://dart.dev/diagnostics/invalid_use_of_visible_for_testing_member)

on this code:

class _LifecycleObserverState extends State<LifecycleObserver>
    with WidgetsBindingObserver {
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    switch (state) {
      case AppLifecycleState.resumed:
        Adjust.onResume();
        break;
      case AppLifecycleState.paused:
        Adjust.onPause();
        break;
      case AppLifecycleState.inactive:
      case AppLifecycleState.detached:
      case AppLifecycleState.hidden:
        break;
    }
  }
}

I understood that those calls are not needed anymore, aren't it?

uerceg commented 1 month ago

Hey @monisnap-jeremie,

Correct, feel free to remove that code snippet entirely from your app and things should work just fine.

monisnap-jeremie commented 1 month ago

Thank you @uerceg 🙏

uerceg commented 1 month ago

And as far as @LegendGin's issue is concerned, it might be happening because you were subscribing to LifecycleObserver and it might have fired a call to Adjust.onResume() before you have initialized SDK v4. In theory, there's no harm if that happens, SDK is logging this just FYI.

I'll close this ticket, but in case you have any further or follow up questions, feel free to comment/reopen.

Cheers and sorry for a delay in replying.