I'm trying to use AccountManager to store account information and have implemented an authenticator, but I keep getting exceptions like the below that crash the phone. Comparing with sample code this seems to be because I don't have (or particularly want) a SyncAdapter and associated service. Is there a trick to using AccountManager without adding a SyncAdapter?
Regards
Phil
I/AuthenticatorActivity( 8526): onAuthenticationResult(true)
I/AuthenticatorActivity( 8526): finishLogin()
W/dalvikvm( 8108): threadid=13: thread exiting with uncaught exception (group=0x
4001b170)
E/AndroidRuntime( 8108): Uncaught handler: thread android.server.ServerThread ex
iting due to uncaught exception
E/AndroidRuntime( 8108): *** EXCEPTION IN SYSTEM PROCESS. System will crash.
E/AndroidRuntime( 8108): java.lang.NullPointerException
E/AndroidRuntime( 8108): at com.android.settings.ManageAccountsSettings.o
nSyncStateUpdated(ManageAccountsSettings.java:187)
E/AndroidRuntime( 8108): at com.android.settings.ManageAccountsSettings.o
nAccountsUpdated(ManageAccountsSettings.java:244)
E/AndroidRuntime( 8108): at android.accounts.AccountManager$10.run(Accoun
tManager.java:826)
E/AndroidRuntime( 8108): at android.os.Handler.handleCallback(Handler.jav
a:587)
E/AndroidRuntime( 8108): at android.os.Handler.dispatchMessage(Handler.ja
va:92)
E/AndroidRuntime( 8108): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 8108): at com.android.server.ServerThread.run(SystemSer
ver.java:435)
I have the same problem. I implemented a AccountAuthenticator, that adds the Account directly in the addAccount-method, because I don't need user input in my case.
I get the Exception after I created the Account and want to view the "Accounts & sync" preference screen. It isn't cause by the creation, because it works with the "Dev Tools > AccountsTester".
edit: I think this is the explanation, I will try it.
"[...] The crash is caused by an undocumented assumption in the Android code that handles accounts and sync. They are very closely related. It turns out that the "Accounts and Sync" settings plugin after getting the accounts on the system, uses the content service to scan for services on the system that implement the intent "android.content.SyncAdapter".
Since our code doesn't implement this, the search came up empty handed and since the code assumed this would never happen, BAM, null pointer exception and crash. [...]" from: http://osdir.com/ml/Android-Developers/2009-11/msg05288.html
In the end I needed to add a SyncAdapter and a ContentProvider. Just the barest stub implementations, but it seemed to do the job. I also think I found that the problem doesn't occur on 2.2
It's a known issue: http://code.google.com/p/android/issues/detail?id=5009
The NPE occurs because no corresponding sync adapter is found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With