title: SyncAdapter stopped syncing
body: <p>Our implementation of SyncAdapter is not syncing with android version 4.4.4. Works well with lower API devices.</p>
  
  <p>Our app uses an <a href="http://developer.android.com/reference/android/content/AbstractThreadedSyncAdapter.html" rel="nofollow noreferrer">AbstractThreadedSyncAdapter</a> to communicate with the server. I've tested it with many different devices and models, running android from API level 10 onwards. We recently acquired two Android 4.4.4 based devices (Moto E, Nexus 5) and started having trouble with the SyncAdapter. Here's the xml config:</p>
  
  <pre><code>&lt;sync-adapter 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:contentAuthority="our.provider"
      android:accountType="our.authenticator"
      android:userVisible="false"
      android:allowParallelSyncs="false"
      android:isAlwaysSyncable="true"
      android:supportsUploading="true" /&gt;
  </code></pre>
  
  <p>Even if I put the manual and expedited flags the sync doesn't trigger:</p>
  
  <pre><code>Bundle bundle = new Bundle();
  bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
  bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
  ContentResolver.requestSync(SyncAdapter.dummyAccount(context), SYNC_PROVIDER, bundle);
  </code></pre>
  
  <p>I'm trying this over WiFi and with the power cord connected to dismiss any power usage-related optimisations. The target SDK is set to the latest version:</p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="10"
      android:targetSdkVersion="20" /&gt;
  </code></pre>
  
  <p>And I have <a href="http://developer.android.com/training/sync-adapters/creating-sync-adapter.html#DeclareSyncAdapterManifest" rel="nofollow noreferrer">all the necessary permissions</a>:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_SYNC_SETTINGS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_SYNC_STATS" /&gt;
  &lt;uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /&gt;
  </code></pre>
  
  <p>There's one thing that strikes me as unusual. The devices report API level = 19, but the SDK says API 19 is equivalent to android 4.4.<strong>2</strong>, instead of android 4.4.4:</p>
  
  <p><img src="https://i.stack.imgur.com/zu8Pb.png" alt="Android 4.4.2 = API level 19"></p>
  
  <p>Could this be related to this issue?</p>
  
  <p>Sorry for not being more helpful or descriptive, but I'm truly out of clues on how to proceed debugging this issue. Thanks in advance.</p>
  
  <h2>Edit</h2>
  
  <p>Further thoughts: </p>
  
  <ul>
  <li><p>Seems to be related to the exponential backoff algorithm that is used when a sync fails. I ended up canceling the request before starting a new one and using a manual sync (ignores backoff). I know this is not ideal, but in my use case the user expects data to be synced inmediately. Make sure to give SyncManager a look: <a href="https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/content/SyncManager.java" rel="nofollow noreferrer">https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/content/SyncManager.java</a></p></li>
  <li><p>Uninstalling the app and running it again solves the issue, so it might be related to the account's permissions. Note that I did remove some unused services from the manifest, but nothing related to the SyncAdapter or its associated classes.</p></li>
  <li><p><a href="http://www.kylook.com/en/questions/?question=8427" rel="nofollow noreferrer">Seems that I'm not alone on this one</a>.</p></li>
  </ul>