This error message is pretty clear:
CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
But I only get this error because I followed the official documentation:
To use the CookieSyncManager, the host application has to call the following when the application starts:
CookieSyncManager.createInstance(context)
To set up for sync, the host application has to call
CookieSyncManager.getInstance().startSync()
in Activity.onResume()
The error occurs only when the application attempts to resume, not when it starts cleanly.
So, I can probably fix that by moving CookieSyncManager.createInstance(context)
to Activity.onResume()
but... won't that create a new problem?
(for example, forgetting the previous session cookies every time the app resumes?)
I followed the official documentation in one of recent apps and CookieSyncMasnager is working just fine...
I have the following:
onCreate()
CookieSyncManager.createInstance(this);
onResume()
CookieSyncManager.getInstance().startSync();
onPause()
CookieSyncManager.getInstance().stopSync();
I am using the activity context in the createInstance(). You don't mention which context you're using?
You also don't mention doing a CookieSyncManager.getInstance().stopSync() in onPause() (or similar). So perhaps for a resume you are calling CookieSyncManager.getInstance().startSync() twice without an intervening stop?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With