Our implementation of SyncAdapter is not syncing with android version 4.4.4. Works well with lower API devices.
Our app uses an AbstractThreadedSyncAdapter 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:
<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" />
Even if I put the manual and expedited flags the sync doesn't trigger:
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);
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:
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="20" />
And I have all the necessary permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
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.2, instead of android 4.4.4:
Could this be related to this issue?
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.
Further thoughts:
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: https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/content/SyncManager.java
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.
Seems that I'm not alone on this one.
While not an answer, this may help. It is, to the best of my knowledge, a completely minimal SyncAdapter.
The example does not have an AccountAuthenticator component. The AccountAuthenticator is required only if there are calls to one of the getAuthToken methods.
As noted in the comments, I tried to duplicate your issue, using this minimal example, and could not do so. Perhaps you can start with it and build to something that fails.
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