SecurityException when trying to add an account

I am experimenting with Android AccountManager .

I have an account authentication service that shows a user interface to enter a username / password.

I go to settings / accounts / add account, select a new type of account and present the user interface.

When I click OK, I get the following error

 04-24 14:48:29.334: E/AndroidRuntime(386): java.lang.SecurityException: caller uid 10035 is different than the authenticator uid 

The only MyAccountAuthenticationService method:

 @Override public IBinder onBind(Intent intent) { return new MyAccountAuthenticator(this).getIBinder(); } 

MyAccountAuthenticator:

 @Override public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException { final Intent intent = new Intent(context, MyAccountCreatorActivity.class); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; } 

Snippet MyAccountCreatorActivity onClick

 AccountManager accManager = AccountManager.get(this); Account newAccount = new Account(email, MyAccountAuthenticator.ACCOUNT_TYPE); accManager.setPassword(newAccount, password); 

An exception is setPassword . I already require all credential permissions. I'm not sure what could be causing this. If you need more code / information, please ask.

Thank.

+6
android accountmanager
Apr 24 2018-12-12T00:
source share
4 answers

Thanks to @imran khan, I found that my constant value does not match “exactly” what was in the definition of the XML authenticator

+4
Apr 24 2018-12-12T00:
source share

It seems obvious, but you will also see this error if your authentication service is not defined in AndroidManifest.xml. For example:

 <service android:name="your.AuthService"> <intent-filter> <action android:name="android.accounts.AccountAuthenticator" /> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator" /> </service> 
+17
Jun 06 '13 at 20:57
source share

In my case, I got this error when I ran two different flavors on the same device. The second tried to access the same account as the first, which caused an error.

+3
Aug 05 '16 at 21:55
source share

In my case, I accidentally defined an AuthenticatorService in a manifest outside of the <application> tags. Moving the declaration inside <application> fixed the problem. Hope will help someone.

+1
May 08 '16 at 16:48
source share



All Articles