1

I have an application with a SyncAdapter. I've read tons of documentation and questions and answers on this and I've fixed a number of issues, but now I'm stuck at this point. We're using Xamarin, so my code is all C#. I created the StubContentProvider from https://developer.android.com/training/sync-adapters/creating-stub-provider.html, except in C#.

Here's my entire AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
    <application android:theme="@android:style/Theme.Light">
        <provider android:name="georgesmobile.android.backgroundservice.StubContentProvider" android:authorities="georgesmobile.android.backgroundservice.provider" android:syncable="true" />
        <service android:name="georgesmobile.android.backgroundservice.SyncService" android:exported="true">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>
            <meta-data android:name="android.content.SyncAdapter" android:resource="@xml/syncadapter" />
        </service>
        <service android:name="georgesmobile.android.backgroundservice.GenericAccountService">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>
            <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator" />
        </service>
    </application>
    <receiver android:name="georgesmobile.android.backgroundservice.BootupReceiver">
        <intent-filter>
            <action android:name="android.intent.action.ACTION_BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_SYNC_STATS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
</manifest>

In my Resources\xml folder I have authenticator.xml:

<?xml version="1.0" encoding="utf-8" ?>
<account-authenticator
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:icon="@drawable/georgeslogo_icon"
        android:smallIcon="@drawable/georgeslogo_icon"
        android:label="@string/AppName"        
        android:accountType="georgesmobile"/>

and syncadapter.xml

<?xml version="1.0" encoding="utf-8" ?>
<sync-adapter
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:contentAuthority="georgesmobile.android.backgroundservice.StubContentProvider"
        android:accountType="georgesmobile"
        android:userVisible="false"
        android:supportsUploading="true"
        android:allowParallelSyncs="false"
        android:isAlwaysSyncable="true"/>

I'm actually trying to set up automatic syncing, but I also tried manually syncing. When I manually sync, I get the error Failed to find provider info for georgesmobile.android.backgroundservice.StubContentProvider

When I manually sync, my SyncService.OnBind() method gets called:

public override IBinder OnBind(Intent intent)
{
    return _syncAdapter.SyncAdapterBinder;
}

and it is after returning from this call (at some point) that I get the error.

What did I miss?

Pete
  • 6,585
  • 5
  • 43
  • 69

1 Answers1

1

Seems that your syncadapter has incorrect content authority. You should use the value of authority instead of the class name of the provider:

<?xml version="1.0" encoding="utf-8" ?>
<sync-adapter
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="georgesmobile.android.backgroundservice.provider"
    android:accountType="georgesmobile"
    android:userVisible="false"
    android:supportsUploading="true"
    android:allowParallelSyncs="false"
    android:isAlwaysSyncable="true"/>
Mikko Liikanen
  • 675
  • 4
  • 8
  • That did fix the error I was getting, so you get the answer and the bounty, though I must admit to feeling a little cheated (not by you, but by me, or Android, or something). Though this issue is now fixed(one of many I've encountered doing this stupid SyncAdapter) my SyncAdapter still doesn't work. The `OnBind()` in my sync service doesn't get called, nor does the `OnPerformSync()` in my SyncAdapter. No errors, no log messages. Whether I call ` ContentResolver.RequestSync` or `ContentResolver.AddPeriodicSync`, I get nothing. – Pete Apr 23 '14 at 18:24
  • Did you check out http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync - it has an excellent answer on what needs to be in place for the sync to work – Mikko Liikanen Apr 25 '14 at 09:45
  • Yes. That question and a few others. Still haven't quite figured it out. – Pete Apr 28 '14 at 19:50
  • @KJEjava48 Yes, I did solve this many moons ago and honestly, I have no recollection of what the final fix was. I ended up working pretty closely with a support guy at Xamarin and as I recall, there were bugs in the framework that needed to be worked around. It took ages to solve and I wish I had the details of the fix because you're not the first to ask. Sorry. – Pete Sep 02 '16 at 17:54