Question

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?

Was it helpful?

Solution

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"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top