I have the following Account authentication classes
public class AppAuthenticator extends AbstractAccountAuthenticator {
private Context mContext;
public AppAuthenticator(Context context) {
super(context);
mContext = context;
}
//This is used by the login activity when the guy logs in after starting the app
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
//...Code Here...
}
}
with
public class AuthenticationService extends Service {
private static AppAuthenticator sAuthenticator = null;
public AuthenticationService() {
super();
}
@Override
public IBinder onBind(Intent intent) {
IBinder res = null;
if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT))
res = getAuthenticator().getIBinder();
return res;
}
private AppAuthenticator getAuthenticator() {
if (sAuthenticator == null)
sAuthenticator = new AppAuthenticator(this);
return sAuthenticator;
}
}
and the manifests: xml/authenticator.xml
<account-authenticator
xmlns:android="http://schems.android.com/apk/res/android"
android:accountType="@string/account_type"
android:label="@string/app_name"
android:icon="@drawable/benchcap" />
androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<application
android:name="com.app.app.AppApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service android:name=".AuthenticationService"
android:exported="true" android:process=":auth">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
</application>
with @string/app_name="App" and @string/account_type="com.app.app"
So the problem is when the application is installed I get
"Unable to load service info ResolveInfo{40f00c40 com.app.app.AuthenticationService p=0 m=0x108000}
Loaded meta-data for 0 account types, 0 accounts in 4ms(wall) 2ms(cpu)"
and I try to add accounts I get the SecurityException "Caller UID is different than the authenticator UID" (described here: SecurityException: caller uid XXXX is different than the authenticator's uid). Which makes sense since the service is not regiestered.
The system gives no more information than that.
What does one need to add to get the authentication service registered properly?