title: CookieSyncManager::createInstance() IllegalStateException?
body: <p>My app started getting a lot of CookieSyncManager exceptions recently:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>The error is clear from the stack trace, but where it's originating from is not (this is from Play store reporting). The user messages attached to the stack traces indicate that it's happening around the place I'm using the facebook SDK, and it does use CookieSyncManager:</p>
  
  <pre><code>// From Facebook.java
  private void startDialogAuth(Activity activity, String[] permissions) {
      ...
      CookieSyncManager.createInstance(activity); // &lt;-- here
      dialog(activity, LOGIN, params, new DialogListener() {
          public void onComplete(Bundle values) {
              CookieSyncManager.getInstance().sync(); // &lt;-- here
              ...
  </code></pre>
  
  <p><a href="https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java#L342" rel="nofollow">https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/android/Facebook.java#L342</a></p>
  
  <p>This looks ok to me, but is there anything wrong with the above usage? I can't reproduce the error on any of my test devices, perhaps there's an implementation difference?</p>
  
  <p>Thanks </p>