SecurityException: caller uid XXXX is different than the authenticator's uid - android

I received the above exception when trying to implement Sample Sync Adapter application. I have seen numerous posts related to this issue but no satisfactory response.
So I will jot down my solution here in case anyone else gets into the same issue.

Some other useful tips to debug problems like this.
First enable verbose logging for some tags:
$ adb shell setprop log.tag.AccountManagerService VERBOSE
$ adb shell setprop log.tag.Accounts VERBOSE
$ adb shell setprop log.tag.Account VERBOSE
$ adb shell setprop log.tag.PackageManager VERBOSE
You'll see logging like this:
V/AccountManagerService: initiating bind to authenticator type com.example.account
V/Accounts: there is no service connection for com.example.account
V/Accounts: there is no authenticator for com.example.account, bailing out
D/AccountManagerService: bind attempt failed for Session: expectLaunch true, connected false, stats (0/0/0), lifetime 0.002, addAccount, accountType com.example.account, requiredFeatures null
Which means that there is no authenticator registered for this account type. To see which authenticators are registered watch the log when installing the package:
D/PackageManager: encountered new type: ServiceInfo: AuthenticatorDescription {type=com.example.account}, ComponentInfo{com.example/com.example.android.AuthenticatorService}, uid 10028
D/PackageManager: notifyListener: AuthenticatorDescription {type=com.example.account} is added
I had the problem that the authenticator xml descriptor referred to a string resource which didn't get resolved properly during the installation:
android:accountType="#string/account_type"
The logs showed
encountered new type: ServiceInfo: AuthenticatorDescription {type=#2131231194}, ...
Replacing it with a normal string (not resource) solved the problem. This seems to be Android 2.1 specific.
android:accountType="com.example.account"

First, check the condition explained on this post:
[...] If you see an error from the AccountManagerService of the form caller uid XXXX is different than the authenticator's uid, it might be a bit misleading. The ‘authenticator’ in that message is not your authenticator class, it’s what Android understands to be the registered authenticator for the account’s type. The check that happens within the AccountManagerService looks like this:
private void checkCallingUidAgainstAuthenticator(Account account) {
final int uid = Binder.getCallingUid();
if (account == null || !hasAuthenticatorUid(account.type, uid)) {
String msg = "caller uid " + uid + " is different than the authenticator's uid";
Log.w(TAG, msg);
throw new SecurityException(msg);
}
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "caller uid " + uid + " is the same as the authenticator's uid");
}
}
Note that hasAuthenticatorUid() takes the account.type. This is where I’d screwed up. I was creating my Account with a type specified by a constant:
class LoginTask {
Account account = new Account(userId, AuthenticatorService.ACCOUNT_TYPE);
...
}
class AuthenticatorService extends Service {
public static final String ACCOUNT_TYPE = "com.joelapenna.foursquared";
...
}
but this constant did not match the XML definition for my authenticator:
<account-authenticator xmlns:android="/web/20150729061818/http://schemas.android.com/apk/res/android"
android:accountType="com.joelapenna.foursquared.account" ... />
Second, if you are like me and want to embed the sample into your existing app for testing then, make sure you use Constants class that is part of this example and not under android.provider.SyncStateContract package. Because both classes use the same attribute name ACCOUNT_TYPE that is used when creating Account object.

In my case the problem was very simply a mismatch in accountType declared in res/xml/authenticator.xml as android:accountType="com.foo" but referenced incorrectly as "foo.com" in creating the Account:
Account newAccount = new Account("dummyaccount", "foo.com");
Doh!

There are few parts to implement custom account...
To invoke AccountManager in your Activity, something like that you already implemented...
Account account = new Account(username, ACCESS_TYPE);
AccountManager am = AccountManager.get(this);
Bundle userdata = new Bundle();
userdata.putString("SERVER", "extra");
if (am.addAccountExplicitly(account, password, userdata)) {
Bundle result = new Bundle();
result.putString(AccountManager.KEY_ACCOUNT_NAME, username);
result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCESS_TYPE);
setAccountAuthenticatorResult(result);
}
In res/xml/authenticator.xml you have to define your AccountAuthenticator data (responsible for your Authenticator UID). ACCESS_TYPE have to be the same string as your defined accountType in this xml!
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="de.buecherkiste"
android:icon="#drawable/buecher"
android:label="#string/app_name"
android:smallIcon="#drawable/buecher" >
</account-authenticator>
Finally you have to define your service your Manifest. Please do not forget the relevant permissions for manage your accounts (AUTHENTICATE_ACCOUNTS / USE_CREDENTIALS / GET_ACCOUNTS / MANAGE_ACCOUNTS)
<service android:name=".AuthenticationService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>

My error was assuming the AccountManager getAccounts() method returned accounts only associated with my application context. I changed from
AccountManager accountManager = AccountManager.get(context);
Account[] accounts = accountManager.getAccounts();
to
AccountManager accountManager = AccountManager.get(context);
Account[] accounts = accountManager.getAccountsByType(Constants.ACCOUNT_TYPE);

The same error will appear if you put incorrect values in your intent-filters in your manifest.
I went through the android-dev tutorial on sync-adapters and ended up setting a bogus value for the "intent-filter/action android:name" as well as "meta-data/android:name" for syncadapter/accountauthenticator. This mistake caused the same errors to appear in the logs.
For the record, the correct values are: {android.content.SyncAdapter, android.accounts.AccountAuthenticator}

Make sure that your service XML is pointing to the correct location.
For instance if you're module name is
com.example.module.auth
you're service android:name should be
<service android:name=".module.auth.name-of-authenticator-service-class"...
in AndriodManifest.xml

First off, take another look at Jan Berkel's excellent debugging advice.
Finally, another thing to check is that your content provider and the authentication, and sync services are declared as children of the application tag.
<application
...>
<activity
...(Activity)...
</activity>
<provider
...(CP service declaration)/>
<service
...(Authentication service declaration)...
</service>
<service
...(Sync service declaration)...
</service>
</application>

For me it was a very silly mistake and was very hard to find.
In authenticator.xml I wrote
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.myapp"
android:icon="#drawable/ic_launcher"
android:smallIcon="#drawable/ic_launcher"
android:label="#string/app_name"
/>
instead of
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.myapp"
android:icon="#drawable/ic_launcher"
android:smallIcon="#drawable/ic_launcher"
android:label="#string/app_name"
/>
which was causing this error. Hope this helps someone!

In my case it was permissions in manifest file
i had
<uses-permission android:name="ANDROID.PERMISSION.GET_ACCOUNTS"/>
it was all caps, when i changed it to
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
problem was gone

Also,
Check to see if you are treating the AccountType too much like a plain-old-String.
I have most of my code packaged under com.mycompany.android
I have been using the following AccountType with success: com.mycompany.android.ACCOUNT.
Now I have a desire to use multiple accounts, and when I try the approach of appending ".subType" on the end of my account, it fails with the
caller uid xxxxx is different than the authenticator's uid
However, if I use "_subType" ( underscore instead of dot ), it works fine.
My guess is that somewhere under the hood Android is trying to treat com.mycompany.android.ACCOUNT as a legal package name, which it most certainly is not.
So, again:
BAD com.mycompany.android.ACCOUNT.subType
GOOD com.mycompany.android.ACCOUNT_subType

If you are getting this error, and all the above solutions are not working for you. Also, you assume that you have followed all the procedure. There may be a chance that the Authentication Service is developed by some other developer, which you want to make use of to Add Accounts.
What you can try is try signing your application with a release keystore. Now you run the application. I suppose this should work for you.

Here is another one possible solution.
I had this error when my user was registered in my app with the same e-mail as his android google account.
So, when I tried to accountManager.getAccounts() and search for this e-mail I found an account with the same e-mail BUT with another account type. So, when trying to use this (google.com) account I get this error.
So, the right way to find an account is:
public Account findAccount(String accountName) {
for (Account account : accountManager.getAccounts())
if (TextUtils.equals(account.name, accountName) && TextUtils.equals(account.type, "myservice.com"))
return account;
return null;
}

Also make sure your AccountAuthenticatorService has the prover intent filters ;
ie.
<service android:name=".service.AccountAuthenticatorService">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="#xml/authenticator" />
</service>

If you get this exception at Samsung devices be sure that you are not using safe mode.

If same apps are from different store ,for example amazon app store and google play store , eventually security exception gonna be thrown as the signature of the apps would be different in this case .If u had planned to use same authenticator for the purpose of single sign in , either of the app would crash. i had encountered this trouble once. Especially amazon app store would sign its apps with its own signature for the purpose of security.
Note: If there is no typo error or other answers mentioned here , please check for the signature of the apps in case of single sign in.

For those who still expierienced issue: https://stackoverflow.com/a/37102317/4171098
In my case I accidently defined AuthenticatorService in the Manifest
outside the <application> tags. Moving the declaration inside
<application> fixed the issue. Hope will help someone.

Related

Issue with adding ROLE_ASSISTANT

Now that Android 10 & above has this feature, I'm trying to add it. Included this in the manifest:
<action android:name="android.intent.action.ASSIST"/>
And here's the code:
mRM = (RoleManager) mAppContext.getSystemService(Context.ROLE_SERVICE);
bAvailable = mRM.isRoleAvailable(RoleManager.ROLE_ASSISTANT);
if (bAvailable) {
roleIntent = mRM.createRequestRoleIntent(RoleManager.ROLE_ASSISTANT);
startActivityForResult (roleIntent, REQUEST_CODE);
}
But, I keep getting this error:
RequestRoleActivity: Role is not requestable: android.app.role.ASSISTANT
RequestRoleFragment: Role request result requestingUid=10021 requestingPackageName=com.broadcom.BcmMicCapture roleName=android.app.role.ASSISTANT qualifyingCount=-1 currentUid=-1 currentPackageName=null grantedAnotherUid=-1 grantedAnotherPackageName=null result=1
Any idea what's amiss here? Is it a sepolicy issue? Or the app needs to add some other permissions?
Unfortunately this is not possible anymore.
Google made this role not requestable:
https://cs.android.com/android/_/android/platform/packages/modules/Permission/+/3512ea1e5dd8b91f0017dfdb523b3421f7b165e2

Azure Authentication with AAD & Google in a Xamarin Forms Project not Redirecting back to app after Authorized

Azure Active Directory
Google+ Auth
Xamarin Forms, PCL (NuGet 2.4.0.282)
Microsoft.Azure.Mobile.Client 4.0.0 & 4.0.2
After I successfully Login my phone does not return to my app. I have two test phones and one emulator, they display different info, after login.
Phone 1 (AAD Auth):
Phone 1 (Google Auth it greys out and just keeps "loading")
Phone 2 (AAD and Google Auth):
Emulator (AAD and Google Auth):
I have done everything I found here on Stack OverFlow, that makes sense and seems to be applicable to current versions of NuGets.
This person seems to be having a similar issue to me but with Google Log in
Azure not redirecting after loginenter link description here
I have tried integrating code into my project. And then I input my Azure info into Xamarin's sample: https://github.com/xamarin/xamarin-forms-samples/tree/master/WebServices/TodoAzureAuth
And I get the same results. I have tried both AAD and Google+ Auth. After login it just stays at the browser. So I feel like the client side code has to be correct. But I cant find any mess up on my Azure server code. I have tried this with projects that have a C# and Node.Js backend.(For one of my projects) My ALLOWED EXTERNAL REDIRECT URLS is ToDoList53172://easyauth.callback and in my AndroidManifest.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.sample.TodoAzure">
<uses-sdk android:minSdkVersion="15" />
<application android:label="TodoAzure" android:icon="#drawable/icon">
<activity android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity" android:launchMode="singleTop" android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="ToDoList53172" android:host="easyauth.callback" />
</intent-filter>
</activity>
</application>
</manifest>
OLD:
And I don't feel like I should post all the other code. It is all in the Xamarin sample project posted above. If people think I should I will.
NEW:
I am adding more code just to help people out. I did not want to overload, but better to have all the info in one place. So here is my MainActivity.cs Code
using System;
using System.Threading.Tasks;
using Android.App;
using Android.Content.PM;
using Android.OS;
using Microsoft.WindowsAzure.MobileServices;
using Android.Webkit;
namespace TodoAzure.Droid
{
[Activity(Label = "TodoAzure.Droid",
Icon = "#drawable/icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
Theme = "#android:style/Theme.Holo.Light")]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity, IAuthenticate
{
MobileServiceUser user;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
App.Init((IAuthenticate)this);
LoadApplication(new App());
}
public async Task<bool> AuthenticateAsync()
{
bool success = false;
try
{
if (user == null)
{
// The authentication provider could also be Facebook, Twitter, or Microsoft
user = await TodoItemManager.DefaultManager.CurrentClient.LoginAsync(this, MobileServiceAuthenticationProvider.Google, Constants.URLScheme);
if (user != null)
{
CreateAndShowDialog(string.Format("You are now logged in - {0}", user.UserId), "Logged in!");
}
}
success = true;
}
catch (Exception ex)
{
CreateAndShowDialog(ex.Message, "Authentication failed");
}
return success;
}
public async Task<bool> LogoutAsync()
{
bool success = false;
try
{
if (user != null)
{
CookieManager.Instance.RemoveAllCookie();
await TodoItemManager.DefaultManager.CurrentClient.LogoutAsync();
CreateAndShowDialog(string.Format("You are now logged out - {0}", user.UserId), "Logged out!");
}
user = null;
success = true;
}
catch (Exception ex)
{
CreateAndShowDialog(ex.Message, "Logout failed");
}
return success;
}
void CreateAndShowDialog(string message, string title)
{
var builder = new AlertDialog.Builder(this);
builder.SetMessage(message);
builder.SetTitle(title);
builder.SetNeutralButton("OK", (sender, args) => { });
builder.Create().Show();
}
}
}
And Like I said above I have tried this with AAD as well. The code above is for Google.
Here is my Azure Auth setup
Here is the info I get after logging in with "https://todolistjbb.azurewebsites.net/.auth/login/aad" and then visiting
"https://todolistjbb.azurewebsites.net/.auth/me"
I feel like I have tried SO many things. I have recorded 66.68 hours working on just trying to get Authentication in my app.... please... someone tell me what I am doing wrong! I am losing it over here :'(
The way to solve this problem is do not start with a capitalized letter for your Url Scheme. It took me over 2 weeks to figure it out. I don't think this sis written anywhere, but I am sure it is.
So yeah to fix this i switched "ToDoList53172" to "todolist53172"
That's it... Oy vey!
According to your description, I assumed that you are using the Server-managed authentication provided by Azure App Service authentication/authorization. Since you are using the Microsoft.Azure.Mobile.Client >= 4.0.0, for your mobile client, you would leverage the following code snippet for logging via the server-flow:
var user = await client.LoginAsync(this, provider, "{url_scheme_of_your_app}");
Details you could follow Add authentication to the app. Moreover, you need to Add your app to the Allowed External Redirect URLs.
Based on the error message from your phone 2:
todolistjbbservice://easyauth.callback/#authorization_code=xxxxx
It seems that you did not configured the Authorized Redirect URI correctly. For the Azure Active Directory provider, you could follow here for registering your Web App / API or Native application. For the Google provider, you could follow here.
After correctly configured your preferred identity provider(s), you need to add your app to the Allowed External Redirect URLs:
Log into Azure Portal, choose your App Service
Click the Authentication / Authorization,
enter ToDoList53172://easyauth.callback in the Allowed External Redirect URLs, and save your changes.

Push notification reaching ios (apns) but not android (gcm) device

So I have a simple Ruby app that uses Rpush to send push notifications to my iphone and my android phone. Right now all it does is sends it to the iphone. I am not sure whether the problem is with my script (i.e. incorrect values for the registration_id, app_name, or auth_key), or whether the problem is how I have my Android app configured.
The relevant part of that code is here (values changed for security - but format/length of keys left untouched to make sure they "look right" to people with experience)
API SETUP/RATIONALE (Sending the notification)
# GCM
app = Rpush::Gcm::App.new
app.name = "MyApp"
app.auth_key = "POfaSyfghilK3l-ueSvRLmbawcRThCWkwmcYGeM"
app.connections = 1
app.save
n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("MyApp")
n.registration_ids = ["derGV80JK-s:APA91bHgerskBnrhHndes947nMKxI116tC3-k-tGd-hT5NzVc8QAWEkvCrMwrvs78RUL8-vvhp2ultoevqzZnn8gsr9t6WDXDYpGfCliqaJzj0XByBgbi0bm-rYufjcxfCc_5lEL381F"]
n.data = { message: "testing!" }
n.save!
Rpush.push
I determined that the name of my app was "MyApp" by looking at my google developer console here and noticing that the "Project Name" of the desired project is "MyApp".
I determined the Auth Key on the same site, by navigating to API & Auth -> Credentials -> API Key and copy/pasting the API key from there.
I determined my device's registration id using this code in the main activity of my Android App:
public static String getDeviceID(Context context) {
final TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, tmPhone, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "";// + tm.getSimSerialNumber();
androidId = ""
+ android.provider.Settings.Secure.getString(
context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(),
((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
When logged, getDeviceID shows me the registration id that I specified in the above ruby code.
APP SETUP/RATIONALE (Receiving the notification)
First, I set up my Android Manifest to have all the necessary permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.johncorser.myapp.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.johncorser.myapp.permission.C2D_MESSAGE" />
Then, I set up a listener service to react to push notifications:
<service
android:name="com.johncorser.myapp.services.GcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
That class is very simple and looks like this:
public class GcmListenerService extends com.google.android.gms.gcm.GcmListenerService {
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d("push", "From: " + from);
Log.d("push", "Message: " + message);
}
}
I would expect these messages to log out after sending the push notifications. But instead nothing happens (no exceptions thrown on the server or app).
Any one see what I'm doing wrong here?
Why are you using the UUID you generated from the Android Device ID as a registration ID for Google Cloud Messaging?
That's NOT how you get a registration id.
To get a registration ID you have to register with GCM on the device and receive back a registration ID/token, as described in Cloud Messaging for Android Quickstart:
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
In order for the above code to work you need to have a google-services.json configuration file (which is parsed by the com.google.gms.google-services gradle plugin, that you also need) in your app/ directory and you need the gcm_defaultSenderId which is the Project ID (Number) you get from the Google Developers Console.
You can easily generate that file and receive the above details by clicking the button "Get a configuration file" and following the steps mentioned there.
The code to get the registration ID needs to be in an IntentService as described here, and you need to define the service in the AndroidManifest.xml file as outlined here
For GCM to be able to communicate with your app, you also need to define in the manifest file a com.google.android.gms.gcm.GcmReceiver which has an intent filter with an action name "com.google.android.c2dm.intent.RECEIVE" and a category name with your package name. Look here for an example.
Try running the sample here by Google themselves.
https://developers.google.com/cloud-messaging/android/start
https://github.com/googlesamples/google-services/tree/master/android/gcm
I feel like something might just be missing in your manifest file.
Hope that helps.
In case anyone else runs in to this, the problem was that I did not whitelist my IP address on developers.google.com. I now have it set so all IPs are whitelisted, and it works like a charm.

ACRA : Configured to send report on mail but not getting any mail

I am trying to configure ACRA for the first time. I have followed the Basic Setup guide :
1.Integrated the acra jar file to my app
2.Created a new class extending application class and have added the below code to it :
#ReportsCrashes(formKey = "", // will not be used
mailTo = "mymailId#gmail.com")
public class MyApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
ACRA.init(this);
}
}
3.Made all necessary changes to manifest file
It seems that all is done correctly,I am able to get the below in logcat :
12-21 14:59:10.994: D/ACRA(28728): ACRA is enabled for com.android.demo.notepad1, intializing...
12-21 14:59:11.064: D/ACRA(28728): Using default Mail Report Fields
12-21 14:59:11.064: D/ACRA(28728): Looking for error files in /data/data/com.android.demo.notepad1/files
12-21 14:59:11.074: W/ACRA(28728): **com.android.demo.notepad1 reports will be sent by email (if accepted by user).**
But I am not able to get any mail :( !
As far i know, the mailTo option needs the user in order to send the email.
When an error occurs another mail client (such as Gmail.apk) has to be open to process the crash report and send e-mail. So the error will open a mail client and we need the user to click on send button.
Although a bit late, someone might find it useful anyways...
I did have at least a similar problem with ACRA 4.5.0 which I was able to resolve once all the other configuration options were actually set. This means – although partially labeled as optional – I had to give a value to the following options (in the #ReportsCrashes annotation)
resDialogText = R.string.crash_dialog_text, // Text to display upon crash
resDialogIcon = android.R.drawable.ic_dialog_info, //optional (apparently not). default is a warning sign
resDialogTitle = R.string.crash_dialog_title, // optional (apparently not). default is your application name
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional (apparently not). when defined, adds a user text field input with this text resource as a label
resDialogOkToast = R.string.crash_dialog_ok_toast // optional (apparently not). displays a Toast message when the user accepts to send a report.
Though I had mode = ReportingInteractionMode.DIALOG, set which might be the source of my problems at least.
have not used "mailTo" field ,had only used #ReportsCrashes(formKey = "formkey")
Make sure you get the form key from google drive correctly
And on crash you will be getting the report on Google drive excel file
And also make sure you have added Internet permission and Added "MyApplication" in mainfeast
<manifest ...>
<application ... android:name="MyApplication">
...
</application>
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
</manifest>
Detail explanation is provided here http://acra.ch/

Trying to add a gmail account programmaticaly in android but getting error "caller uid 10040 is different than the authenticator's uid"

There is an emial application in android that allows to add email account. How can I add a gmail account in that application programmatically?
I used this link Add account automatically but
got SecurityException "caller uid 10040 is different than the authenticator's uid".
I used that code with
Account account = new Account("my id#gmail.com", "com.example.addaccount.account");
Where "com.example.addaccount.account" is package name of my application, and I added authenticator.xml file in a folder named xml, with same package name android:accountType="com.example.addaccount.account".
But I am getting error "caller uid 10043 is different than the authenticator's uid". Can any one please tell me, what am I missing? I just added the xml file and wrote that code to add account, do I need to refer to that xml somehow?
This method return the android market gmail account
public String getAccount(){
String email=null;
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
for (Account account : accounts) {
email=accounts[0].toString();
}
return email;
}
also add this in manifest.xml
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>

Categories

Resources