The process has stopped unexpectedly

I recently got an HTC Hero phone (currently running Android 2.1 "Eclair"). Long story short, I haven't gotten my phone to properly sync with my Facebook contacts.

Originally, I wasn't able to see any Facebook contacts. Then something happened and I started getting updates, but I could only see contacts up to a certain letter, in my case the letter R. Well, that sucked so today I decided to figure out what was happening. I removed my facebook account from my phone, logged out of the app, uninstalled the app updates, etc. And of course now I was in the original state where no contacts would get synced, and I would get the dreaded error box:


The process has stopped unexpectedly. Please try again.

[Force Close]

Armed with a little bit of patience, I bing-ed for a tool to be able to get some diagnostic information and found an Android app called alogcat, with which I was able to send logs to myself via email. This was a good starting point, but for more convenience I connected my phone to my laptop and downloaded the Android SDK which includes adb (Android Debugging Bridge). Once the SDK is installed I ran adb logcat, which connects to the phone and spews all kinds of useful information.

Using adb logcat I can see all my contacts being read by my phone. Then my phone tries to read "event data" (e.g. updates), which it does through a SQL query to the phone's SQLite database (apparently this is how Facebook data is stored locally on the phone). The problem is that the query that the event sync code issues is malformed, which causes the SQLite parser to throw an exception, which only gets caught on the main thread (where the contacts sync code is running). This exception causes among other tihngs, the death of the whole background synchronization process. Apparently it also causes the databases changes to either be deleted or rolled back / not committed.

Here's the relevant log output (some output has been omitted/replaced for <number> etc.)

D/FBDbWriter( 1311): write event to contact db
D/FBDbWriter( 1311): account_name='Alexander Sklar' AND account_type='' AND (sourceid=<number1> OR sourceid=<number2> OR sourceid= OR sourceid=<number3> OR sourceid=<number4>)
E/DatabaseUtils(  162): Writing exception to parcel
E/DatabaseUtils(  162): android.database.sqlite.SQLiteException: near "OR": syntax error: , while compiling: SELECT _id, sourceid FROM view_raw_contacts_restricted WHERE (1) AND (account_name='Alexander Sklar' AND account_type='' AND (sourceid=<number1> OR sourceid=<number2> OR sourceid= OR sourceid=<number3> OR sourceid=<number4>))
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteProgram.compile(
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteProgram.<init>(
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteQuery.<init>(
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteDirectCursorDriver.query(
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(
E/DatabaseUtils(  162):         at android.database.sqlite.SQLiteQueryBuilder.query(
E/DatabaseUtils(  162):         at
E/DatabaseUtils(  162):         at
E/DatabaseUtils(  162):         at
E/DatabaseUtils(  162):         at

E/DatabaseUtils(  162):         at android.content.ContentProvider$Transport.bulkQuery(
E/DatabaseUtils(  162):         at android.content.ContentProviderNative.onTransact(
E/DatabaseUtils(  162):         at android.os.Binder.execTransact(
E/DatabaseUtils(  162):         at Method)
W/dalvikvm( 1311): threadid=39: thread exiting with uncaught exception (group=0x4001e390)
E/AndroidRuntime( 1311): Uncaught handler: thread pool-4-thread-1 exiting due to uncaught exception
E/AndroidRuntime( 1311): android.database.sqlite.SQLiteException: near "OR": syntax error: , while compiling: SELECT _id, sourceid FROM view_raw_conta
cts_restricted WHERE (1) AND (account_name='Alexander Sklar' AND account_type='' AND (sourceid=<number1> OR sourceid=
<number2> OR sourceid= OR sourceid=<number3> OR sourceid=<number4>))
E/AndroidRuntime( 1311):        at android.database.DatabaseUtils.readExceptionFromParcel(
E/AndroidRuntime( 1311):        at android.database.DatabaseUtils.readExceptionFromParcel(
E/AndroidRuntime( 1311):        at android.content.ContentProviderProxy.bulkQuery(
E/AndroidRuntime( 1311):        at android.content.ContentProviderProxy.query(
E/AndroidRuntime( 1311):        at android.content.ContentResolver.query(
E/AndroidRuntime( 1311):        at
E/AndroidRuntime( 1311):        at
E/AndroidRuntime( 1311):        at
E/AndroidRuntime( 1311):        at java.util.concurrent.ThreadPoolExecutor.runWorker(
E/AndroidRuntime( 1311):        at java.util.concurrent.ThreadPoolExecutor$
E/AndroidRuntime( 1311):        at
I/Process (   81): Sending signal. PID: 1311 SIG: 3

So one of two things isn't going right (in light blue in the stack trace)

  1. Either whatever code is obtaining the sourceid values to construct the query is failing, or
  2. The code constructing the query from the obtained sourceid values should deal with the null sourceid and not add it to the query string as it renders an invalid query

Now, if only I could get a hold of the code for the "Facebook for HTC Sense" app I'm pretty sure I'd figure this out soon enough...

Comments (14)
  1. bonnie says:

    i dont understand most of this but can you help me please.  i have contacted htc and sprint to no avail and i am not a programmer.

    i am getting the same error message when attempting to sync contacts to the htc evo from outlook 2007.  the htc sync tech is of no use.  

    is there an app for me to download to fix this problem?  should i download and install android SDK debugging bridge on my phone?  laptop?  

    i dont use facebook or google for contacts or calendars?  

    ANY help you provide would be IMMENSELY helpful.  i have struggled with this phone since July and htc keeps saying there is going to be a fix but there never is.

  2. Tony says:

    You ROCK.  I hope you get it figured out so I can get rid of mine after you post the fix!

  3. Sadoc says:

    Oh dude! This is awesome! In 4 months this is the very first clear explanation of what happens with this error

    So it seems it just some kind of bug, probably within the Facebook for HTC Sense application

    Have you tried to write to the author of that application? I can do it if you didn't

    Thanks a lot!

  4. Frans Jongma says:

    If this is the SQL generated and if you have items to synchronize, then when single quotes appear in the item (such as 'Joe's birthday', then the generated SQL will fail with a syntax error.

    Pretty bad programming practice. !!!

  5. Chris says:

    any luck yet regarding this problem.  U would be a major hero if u could fix this based on all the complaints!!

  6. Unfortunately I have no control over whether facebook or HTC fix this issue; I have contacted both Facebook and HTC about this but gotten no response whatsoever… On the plus side, I eventually got my facebook sync working by updating the facebook app to the latest version, removing my account and re-adding it (it didn't work right away so I kept trying…hey, I was bored). I'm not going to touch my config now that I've gotten it to sync 🙂 Hopefully HTC / Facebook realize this problem affects a lot of users and act accordingly…

  7. Laura says:

    Good job.  Too often we skip over the simple fix.  However, it's people like you that figure out the base problem and bring it to the attention of those who have access.  Thanks again!

  8. cheryl says:

    I've been having similar issues with my htc hero.  I love the phone but I do use it a lot for facebook which I cannot get any answers from telus about.  I'm not getting all of my contacts coming through to 'people' from facebook…Also I can't get the buddy icon, I get an error for that too.  Do you know why that is?  Do you know how to get all the contacts to come through to 'people'?  I've done factory resets and it doesn't help!  I'm so frustrated!

  9. how do you remove & re-ad account on the htc hero….I've been getting these same errors also not all ppl come through to contact card….I've also got an issue with no 'buddy icon'..does anybody know how to fix this?  I've reset my phone a few different times for other issues but these issues are still here!  Since I use my phone for a lot of facebooking it's extremely frustrating…

    Does anyone noitce the battery not holding charge?

  10. I don't run into this problem anymore, I threw away my old HTC Hero with Android and upgraded to a Windows Phone 7 🙂

  11. Sadoc says:

    Hi there,

    I stopped having the problem when I remove my account on "Account & sync", "Facebook for HTC" and remove it. Ok, you don't get your Facebook contacts (I personally use Google contacts), pictures and status don't update, but that's the only thing.

    You still can download "Facebook for Android" which is the application to use Facebook, developed by Facebook.

    Now my battery lasts longer and I don't get that damn error message

  12. Jon-Michael says:

    I get this same message, however, I also get the message "The application Google Services Framework (process stopped unexpectedly. Please try again." Both messages have the button "force close" and when I hit the button, my phone loads for a moment, and then both messages pop up again. Because of this, I am unable to do anything on the phone, so I can't try any of the suggestions such as a factory reset. Is there anything else that I can try.

  13. Mark Lammas says:

    I have an HTC One SV, Same problem has occurred with two of these phones in succession. I think there is some kind of bug in the core HTC sync software on these phones, I found a workaround, which has fixed my phone at least until the conditions recur which cause the corruption on the phone. I powered down my phone, then removed my battery and my SIM card. I waited a few moments to make sure all memory on the phone was well dead and empty. I then reinserted the battery and booted up again, without the SIM card present. It took longer than usual to boot. When it finally booted, the phone was clear of the offending problem. The weather widget, which had disappeared from my screen mysteriously, reappeared, and the stuck sync symbol on the notification bar of my phone had vanished. I again powered down, removed the battery and replaced the SIM card. This time, reboot was normal, and no further problem, so far, with the phone.

    1. Mark Lammas says:

      This is the fix I have used myself for ages to clear this damned problem, but now it no longer seems to work on this phone. Guess I will have to do a factory reset and reinstall everything.

Comments are closed.

Skip to main content