Error that says: user lacks android.permission.MANAGE_ACCOUNTS

2,874 views
Skip to first unread message

Aaron

unread,
Mar 1, 2011, 4:39:06 PM3/1/11
to google-api-java-client
I rolled out a new version of my Android app that is integrating with
the gdata-java-client library (version 1.0.0-alpha). My application
is an inventory application for comic books - this new feature let's
the user export the data into a google docs spreadsheet. I followed
the picasa example pretty closely and had it all working in just a
couple of days.

Once I rolled the application out I received an e-mail telling me that
a user is getting a force close on the application here is a stack
trace of the exception:

java.lang.SecurityException: caller uid 10091 lacks
android.permission.MANAGE_ACCOUNTS
at android.os.Parcel.readException(Parcel.java:1218)
at android.os.Parcel.readException(Parcel.java:1206)
at android.accounts.IAccountManager$Stub
$Proxy.invalidateAuthToken(IAccountManager.java:546)
at
android.accounts.AccountManager.invalidateAuthToken(AccountManager.java:
301)
at
com.flyingspheres.android.inventory.Enter.authenticateUser(Enter.java:
814)
at com.flyingspheres.android.inventory.Enter.onCreate(Enter.java:193)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2544)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2621)
at android.app.ActivityThread.access$2200(ActivityThread.java:126)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
1932)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4595)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

It seems the obvious conclusion is that the user does not have access
to "Manage Accounts" but that doesn't seem possible is it? Is there
something else happening that is causing the excpetion? Has anyone
else seen anything like this?

I'll start doing a deep dive into the android code but I was hoping
that someone had run into this before I got over my head...

Thanks for your time!

-Aaron

Spiral123

unread,
Mar 1, 2011, 11:27:11 PM3/1/11
to google-api-java-client
lol. welcome to the wacky world of Android OAuth debugging!

first thing I would recommend is to look at your manifest. You should
have at least:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>

Try adding the following:

<uses-permission
android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
<uses-permission
android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.wise" /
>
<uses-permission
android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely" /
>

The only reason for suggesting this is because your problem sounds
similar to one experienced in the MyTracks project.

Check out their issue 318:
http://code.google.com/p/mytracks/issues/detail?id=318&can=1&q=permission&colspec=ID%20Type%20Component%20Status%20Priority%20Work%20Stars%20Owner%20Summary

Comment #2 is especially relevant: "Sounds easy to fix, though I'm
curious why some Android versions would check this permissions and
others wouldn't."

Nick

Aaron

unread,
Mar 2, 2011, 12:09:55 AM3/2/11
to google-api-java-client
Thanks for the reply!

I am missing the permission:
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>

Adding that permission certainly sounds like it fits my problem.

If I am understanding issue 318 correctly it sounds like different
implementations of Android on various phones may or may not check
permissions the same way (tempted to say correctly). That certainly
makes things a little more exciting (I guess).

I will see if I can get my guy to run a test version with that
permission added to it.

I'll post back and let everyone know if that fixes it.

Thanks Again!

-Aaron



On Mar 1, 10:27 pm, Spiral123 <cumis...@gmail.com> wrote:
> lol.  welcome to the wacky world of Android OAuth debugging!
>
> first thing I would recommend is to look at your manifest.  You should
> have at least:
>
>         <uses-permission android:name="android.permission.GET_ACCOUNTS" />
>         <uses-permission android:name="android.permission.USE_CREDENTIALS" />
>         <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
>
> Try adding the following:
>
>   <uses-permission
> android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
>   <uses-permission
> android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.wise" /
>
>   <uses-permission
> android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely" /
>
>
>
> The only reason for suggesting this is because your problem sounds
> similar to one experienced in the MyTracks project.
>
> Check out their issue 318:http://code.google.com/p/mytracks/issues/detail?id=318&can=1&q=permis...

Aaron

unread,
Mar 5, 2011, 9:55:56 PM3/5/11
to google-api-java-client
Apparently that solved the problem - in case anyone else runs into
it...

The error was reported on an HTC Hero (the 2nd version - released in
fall/winter of 2010) .

I tested without problems on the MyTouch 4G and HTC G2.

Thanks again for the help!

-Aaron
Reply all
Reply to author
Forward
0 new messages