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 com.htc.bgp has stopped unexpectedly. Please try again.
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 dbD/FBDbWriter( 1311): account_name='Alexander Sklar' AND account_type='com.htc.socialnetwork.facebook' AND (sourceid=<number1> OR sourceid=<number2> OR sourceid= OR sourceid=<number3> OR sourceid=<number4>)E/DatabaseUtils( 162): Writing exception to parcelE/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='com.htc.socialnetwork.facebook' 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(SQLiteProgram.java:117)E/DatabaseUtils( 162): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:66)E/DatabaseUtils( 162): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)E/DatabaseUtils( 162): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:59)E/DatabaseUtils( 162): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1287)E/DatabaseUtils( 162): at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:337)E/DatabaseUtils( 162): at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5136)E/DatabaseUtils( 162): at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5126)E/DatabaseUtils( 162): at com.android.providers.contacts.CContactsProvider2.query(CContactsProvider2.java:173)E/DatabaseUtils( 162): at com.android.providers.contacts.HtcContactsProvider2.query(HtcContactsProvider2.java:3143)E/DatabaseUtils( 162): at android.content.ContentProvider$Transport.bulkQuery(ContentProvider.java:117)E/DatabaseUtils( 162): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:121)E/DatabaseUtils( 162): at android.os.Binder.execTransact(Binder.java:287)E/DatabaseUtils( 162): at dalvik.system.NativeStart.run(Native 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 exceptionE/AndroidRuntime( 1311): 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='com.htc.socialnetwork.facebook' AND (sourceid=<number1> OR sourceid=<number2> OR sourceid= OR sourceid=<number3> OR sourceid=<number4>))E/AndroidRuntime( 1311): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158)E/AndroidRuntime( 1311): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)E/AndroidRuntime( 1311): at android.content.ContentProviderProxy.bulkQuery(ContentProviderNative.java:369)E/AndroidRuntime( 1311): at android.content.ContentProviderProxy.query(ContentProviderNative.java:388)E/AndroidRuntime( 1311): at android.content.ContentResolver.query(ContentResolver.java:202)E/AndroidRuntime( 1311): at com.htc.socialnetwork.provider.task.FacebookDbWriter.syncEvents(FacebookDbWriter.java:716)E/AndroidRuntime( 1311): at com.htc.socialnetwork.provider.task.UserSyncTask.doSync(UserSyncTask.java:421)E/AndroidRuntime( 1311): at com.htc.socialnetwork.provider.task.SyncTask.run(SyncTask.java:53)E/AndroidRuntime( 1311): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)E/AndroidRuntime( 1311): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)E/AndroidRuntime( 1311): at java.lang.Thread.run(Thread.java:1102)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)
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...
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.
You ROCK. I hope you get it figured out so I can get rid of mine after you post the fix!
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!
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. !!!
any luck yet regarding this problem. U would be a major hero if u could fix this based on all the complaints!!
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...
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!
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!
how do you remove & re-ad f.book account on the htc hero....I've been getting these same errors also not all f.book 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?
I don't run into this problem anymore, I threw away my old HTC Hero with Android and upgraded to a Windows Phone 7 :)
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
I get this same message, however, I also get the message "The application Google Services Framework (process com.google.process.gapps)has 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.