Category Archives: Synchronization

SyncAdapter change in Jelly Bean

Recently, when trying one of my apps that uses a SyncAdapter out on the new Jelly Bean emulator, I got the following exception:

java.lang.IllegalStateException: Already released
at android.content.ContentProviderClient.release(ContentProviderClient.java:242)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:263)

I apparently made the error of releasing the ContentProviderClient passed in onPerformSync() by calling provider.release();.at the end. While this would seem to me to be good practice, and Android didn’t complain up to Jelly Bean, this now throws an exception and causes havoc with random background crashes.

So to sum up: Don’t release() the ContentProviderClient when your SyncAdapter has finished