gpt4 book ai didi

android - CookieSyncManager::createInstance() IllegalStateException?

转载 作者:太空宇宙 更新时间:2023-11-03 10:52:13 25 4
gpt4 key购买 nike

我的应用最近开始出现大量 CookieSyncManager 异常:

java.lang.IllegalStateException: CookieSyncManager::createInstance() 
needs to be called before CookieSyncManager::getInstance()
at android.webkit.CookieSyncManager.getInstance(CookieSyncManager.java:81)
at android.webkit.CookieManager$2.run(CookieManager.java:532)
at java.lang.Thread.run(Thread.java:1096)

从堆栈跟踪中可以清楚地看出错误,但错误的来源却不是(这是来自 Play 商店报告)。附加到堆栈跟踪的用户消息表明它发生在我使用 facebook SDK 的地方,并且它确实使用了 CookieSyncManager:

// From Facebook.java
private void startDialogAuth(Activity activity, String[] permissions) {
...
CookieSyncManager.createInstance(activity); // <-- here
dialog(activity, LOGIN, params, new DialogListener() {
public void onComplete(Bundle values) {
CookieSyncManager.getInstance().sync(); // <-- here
...

https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java#L342

这在我看来没问题,但是上面的用法有什么问题吗?我无法在我的任何测试设备上重现该错误,也许存在实现差异?

谢谢

最佳答案

应该像异常说的那样:

public void onComplete(Bundle values) {
CookieSyncManager.createInstance( activity ); // <-- this line was missing
CookieSyncManager.getInstance().sync();
...

关于android - CookieSyncManager::createInstance() IllegalStateException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11620168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com