Using this code throws that exception and doesn't add created account into account manager.
AccountManager am = AccountManager.get(activity);
Account acc = new Account(name,activity.getString(R.string.account_type));
am.addAccountExplicitly(acc,"Password",null);
I have followed this - http://developer.android.com/training/id-auth/custom_auth.html
Any idea why it is caused?
//edit: Caused by: java.lang.SecurityException: caller uid 10035 is different than the authenticator's uid
The documentation for AddAccountExplicitly say:
The SecurityException that is thrown explains the problem, the UID of the application that is trying to add the account is different from the UID of the authenticator. In other words they are two different applications.
If you want these two to be separate applications you could make sure you share the UID between them. See the android:sharedUserId section of this page for a bit more information on how to do that.
have you tried setting permissions in the manifest, i suspect you may need this?