If you are one of the unlucky ones who can’t make the original Facebook Application to sync its contacts with your phone / Google contacts on Custom ROMs such as AOKP , ( CyanogenMod ) CM9 or MIUI . This solution is the solution for you. It ‘will make the original FB application Sync it’s contacts with the Contacts app. I’ve created a flashable zip method using CWM and another one using ADB+Windows as well.
This will enable Sync dialog on the original Facebook application , just like it used to do on Gingerbread.
Update [Aug 1] : Files Updated.
Based on MIUI 2.7.27 , CM9 2012-07-31 & AOKP MileStone 6Update ->I won’t be able to update the files weekly anymore. But i will try to update them whenever i can get them to be updated.
Files are available at the bottom of this post. Read the instructions if you don’t want to see a lot of FC’s popping up.
Note:
- If the Contact Pictures are not loading, give it some time and keep the contacts application on with internet connected. It is slow , and it is because of slow FB servers.
- If this whole thing leaves you into a bootloop ( very unlikely ) or lot of FC’s ( very much likely if you didn’t reboot / if you flashed the wrong zip ) , You can reflash your current ROM to fix it. Eg: If you were on the CM9 2012-07-31 , flash the CM9 2012-07-31.zip again over your phone. No need to wipe and no need to format to revert this -hack- back.
PreRequisites
- You should have ClockWorkMod ( CWM ) Recovery in your phone for doing it via Method#1.
- You should be having atleast one account or phone number in the phone book , This is to ensure that contacts database is intialized. So -DO NOT- flash this directly after wiping or installing a new ROM, do it after a boot.
Method#1 Using ClockWorkMod Recovery
Files : Download the corresponding file from below( Filenames have date and ROM mentioned)
Steps:
- Copy the appropriate ZIP file for your phone/ROM to your SD card.
- Reboot your phone to recovery mode . You will need ClockWorkMod Recovery 3+ for this tweak to work.
- Go to ‘Mounts and Storage’. Mount ‘data’ ( and ‘datadata’ if it is present ). This step is very important.
- Choose update from sdcard. Locate the ZIP file and update it.
- Reboot.
- Add FB account ( FB accounts which you had added before wont sync properly, so delete it and add again).
- Sync it.
Method#2 - Using Windows+ADB .
Files : Download the corresponding file from below( Filenames have date and ROM mentioned)
- Download the ‘FBSync_ADB_xx’ zip file corresponding to your ROM.
- Extract it to a folder. For eg: to your desktop.
- Connect your phone in debug mode. ( You can enable debugging mode from your phone Under Development > Enable Debugging mode ) .
- Run patch_db.cmd with administrator privileges ( this is a must if you have UAC enabled ). For this, Right click ‘patch_db.cmd’ and select ‘Run as Administrator’
- Reboot the phone.
Warning
- If you wipe the phone/contacts, you will have to flash the zip again.
- Flash it after booting it once onto your phone and adding an account other than FB, preferably. This is to ensure that the database has been created. If you already have accounts , clear them , leave one phone contact preferably.
- I’m not responsible for any data loss. If you mismatch the ROM and ZIP then it’s bound to soft-crash the phone.
Detailed Explanation:
- Facebook application can sync its contacts with the Contacts ( Through ContactsProvider ) only when its whitelisted ( or, in other words , given an escalated permission set ) in the ROM.
- For this , You have to edit the ContactsProvider.apk and add the whitelisted permission.
- For editing the ContactsProvider.apk ( Which resides in the /system/app/ directory) ,You will need smali ( An assembler/disassembler for Android’s dex format ).
- After disassembling the ContactsProvider.apk using smali , Go to the res/values/ folder ( in the disassembled source ) , and add the file ( arrays.xml ) containing the following content:
<?xml version="1.0" encoding="UTF-8"?> <resources> <string-array name="unrestricted_packages"> <item>com.facebook.katana</item> </string-array> </resources> - The com.facebook.katana is the application of facebook. So after adding the arrays.xml file to the /res/values/ folder, Assemble the ContactsProvider using the smali into an unsigned apk file.
- Now , Since ICS , Android 4.0 , Google has disabled this provision of whitelisting applications natively , hence they have obfuscated certain fields from the database.
- Add the column named
is_restricted
to the raw_contacts table inside contacts2.db ( stored in /data/data/com.android.providers.contacts/database/ )
- If you have sqlite enabled ( along with busybox ) in your kernel you can use this command for altering the database and adding the necessary field by running it under ADB Shell:
sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db 'ALTER TABLE raw_contacts ADD COLUMN is_restricted VARCHAR';
- After adding the column, all the facebook accounts added will be provided with Sync Prompt and they will appear under contacts.
Compatibility Reports
[ Refer to my XDA Post ]
Files


no luck!! din works on my ZTE Blade
Give me your “ContactsProvider.apk” from your device. You can use “adb pull /system/app/ContactsProvider.apk”. Can you tell me which ROM you are using now?.
I can’t get it to work on my i777 after formatting my phone and reinstalling everything! Please help. I’m running the latest version of AOKP.
Your zip file is corrupt if it is not executing in CWM . Your download manager is corrupting it. Download using some other way
Hi,
Tried both automated and manual versions and not syncing even if the table is updated. Running AOKP M5.
Thanks
Give me your “ContactsProvider.apk” from your device. You can use “adb pull /system/app/ContactsProvider.apk”.
Made my G2X slow as crap.
ContactsProvider alone cannot make your phone lag. Yes, it will lag , but only while it’s syncing for the first time. It’s dedicated for contacts storage. Why would it make the phone lag when you are not accessing contacts. Check your other apps.
.
It wasn’t just the contacts, it was the home screen and completely unrelated apps. I’ll try giving it a little time.
It shouldn’t lag the other apps at all, ideally. Did you check the activites for CPU usage. You can do it by ticking “Show CPU Usage” under “Development Tools” in settings. This can’t be in no way related to contacts database. Maybe it’s the FB app , since it’s working now, it might be running your CPU. Tell me if you found out what’s happening.
.
Hey man, this is phenomenal. Should get the word out.
Only one question, will this push the hi-res photos from Facebook to my contacts (picture)? I assumed it would since the actual sync worked, but I have been messing with my gnex for about 10 minutes and it doesn’t seem like the pics are coming over.
It should get the default res pics that the facebook used to pull from fb server in gingerbread. It’s 128px square ones i think on my SGS i9000 .
However the image pull is buggy at times. just remove the fb account and sync again and it will start syncing. It didn’t sync for me in 1 out of 10 times.
Works on a Galaxy S2 Telus/T-Mobile variant. Seemed a bit quirky at first with some FCing, but it sorted itself out. Pretty sure I just wasn’t being patient enough with it. Anyways, synced contacts, but I’m not seeing any pictures.
That is a bug, I do not know what’s happening with that. It is syncing pics with mine But not always. Can you try removing the FB account and try adding it again from “Accounts & Sync” . Also if that doesn’t work , try clearing FB app data.
Also tell me which ROM you were using as well.
. Thanks.
The latest zip files don’t seem to be uploaded correctly? Their file size is only about 50 kb.
Hi, No, they are complete. Are you using a Download accelerator?. That might be causing issue. Please check.
All the download links give me page not available ?
You have to click the link from the page. Copy pasting won’t work.
Links for download leads to a 404.
Thanks for bringing that to attention. Some backend issues came up. Refresh the page , new links will work.
Many Thanks Its Working!!! Cheers. Good Job!
with cm9 on wildfire s method 1 don’t work.. error during zip update..
Are you sure that the zip file is not corrupt?. It is not supposed to show that error if it is not corrupt .
. Second method worked?
Any way to remove this once installed?
Reflash your current ROM. no need to wipe.
Roger that, thanks!
Thanks a lot buddy. The mod works perfectly! I appreciate you shared details about why it works too, keep up the good work.
Great job! I was looking for something like that.
Any Idea if it would work on Slim ICS? I think it is based on AOSP so I’m not sure which zip to download.
Thank you for you effort!
CM9 flash zip should work. Report it if it doesn’t .
Looks like it worked! Thanks!
I can confirm that this is working for the Epic 4G Touch running the 6/17 cm9 nightly. Thank You!
Question: how do I get my peoples app to look like yours(orange, menu changes, etc…)?
Hey, Thanks for reporting . I’m running MIUI , It’s another Android ROM. Not completely AOSP but theme’ng capability is way better . Not CM9 .
.
The links are leading to a 404 page again!
Are you directly linking to the file?. If so , those links won’t work. New links are there at the bottom of the post.
It works on us cellular Samsung galaxy s2 sch-r760 thanks
Dude, your brilliant! Worked on T-Mobile Galaxy SII running the latest AOKP nightly. I did have to clear Facebook data and remove and add the account under “Accounts and Sync” to get the pictures to finally sync.
I am using CM9 nightly dated 13-06-2012 on Galaxy S. Which of the two files should I use? And what’s the difference??
I’ve clearly mentioned which file and what file to use.
. The one nearest to your ROM build.
.
Worked for me no problems on my Sensation running CM9
will it work on galaxy s plus?
It should work on all phones for these ROMs.
Just tried it through CWM on my Galaxy SII Skyrocket running AOKP 40, works flawlessly.
Now I have my FB contacts sync’ed OK, but my Whatsapp contacts aren’t sync’ed anymore
(
No co-relation between those. I haven’t done anything with sync adapter code. Can you try re adding the whatapp account?.
Patch don’t work, the phone power off after reboot… i have to format the phone and lose my files.. thanks
You could’ve reflashed your ROM like i mentioned in the post instead of formatting. Your comment doesn’t have any information on which ROM and which Phone. That’s a no thanks.
Just tried this via CWM on a Nexus S running CM9-RC1 and as soon as I booted back into the OS I started getting repetitive messages about different critical system processes stopping. I can’t use my phone. Can I roll this back somehow? Help, please!
Procs that are stopping are google.process.gapps, Google Voice, and Contacts.
Like i have mentioned in the post, unless you are using the exact ROM build/version . This may not work. Those processes are quitting because you flashed the wrong file/version.
Flash the RC1 Zip ( The ROM you are currently having ) again. No need to wipe. it will remove the FC’s and you won’t lose any data.
. No worries.
I will post the patch for 2906 CM9 . Flash that CM9 version and try the corresponding zip , if you want to .
.
Any possibility this could work on JB preview release? http://forum.xda-developers.com/showthread.php?t=1737849
Thanks for your work
As of now, it is not possible to decompile ( patch ) the Jelly Bean files. I will try to do it as soon as i am able to do it.
.
Hello, source code of JB is out… could you please do a fix for this version or at least write down how to make ourselves? Much appreciated
You didn’t read the article at all?. It should be the same step. Decompile the mentioned APK using AutoAPKTool or similar tool but with apktool library supporting JB. I do not know whether it’s out.
http://www.xda-developers.com/android/android-4-1-jelly-bean-source-code-released-to-aosp/
Niranjan, MIUI v2.6.29 is out, could you please make a cwm flashable zip for the fix. Thanks a ton!
In a sec. I’m uploading right now actually
.
Some complications. That patch is failing. Let me check it.
Check here tomorrow.
.
Wich one is compatible with this ROM?
forum.xda-developers.com/showthread.php?t=1618757
None of the given ones. You have to patch your ROM’s files yourself,since that is a Source-modified-compiled ROM.
Please compile a package for SlimICS ROM.
I have stopped compiling the zips. i did it for one month. it’s tiresome.
Niranjan Thilak – YOU, my friend – are awesome!!
CWM worked like a charm. EVO4G ROM=cm-9-20120706-UNOFFICIAL-supersonic.zip
Thank you!!!
Just tried the latest with AOKP M6 and it isn’t working
Tried the older one and it worked…
Excellent! Cant thank you enough for this. Im using Resurrection Remix, and the only issue I had, was my contacts not syncing from facebook. It’s sorted now! Much appreciated!
Thanks so much for the hard work!
Device: HTC One S
ROM: CM-9-20120708-unofficial-ville
Method #1: FBSync CM9 2012-06-29 0510, apparently, also works with TWRP, as this is the recovery I have installed on my HTCOS.
Works on LGVM670 Running quattrimus CM9 beta1 using the FBSync ADB CM9 2012-06-29 0510 fix.
Thanks so much for the great writeup. Is the process the same for Jellybean? I understand that jellybean natively syncs phone number, but does not pictures. I tried the above process. Contacts2.db already has the is_restricted column. However, when I installed the altered ContactsProvider.apk – I lost all my contacts and gapps failed (backed up with Ti-backup though). I used apktool the assemble the directory after adding the array xml. I am using PureAOSP jellybean rom for the galaxynexus toro. (I have tried Haxsync – but some of the pictures are cropped unfavorably)
I do not know since i do not have means to check. HaxSync seems your better option. Try out ‘Syncmypix’ .
Seems to work on Galaxy S3 running AOKP M6 too!
it works for lg p500 optimus one AOKP custom rom ???
Do i have to buy a phone and test it !. Check it out dude . It won’t kill your phone. Reflash your AOKP rom again to revert changes if it’s failing.
Working on Motorola Atrix 4G CM9 / AOKP
Hey!! I wanna thank you for the great work! Do you think you can put up a version for CM10?? I am on i9300 International Version, and the only thing stopping me from going to CM10 is the Facebook Sync issue!
I was not able to do the necessary modifications succesfully for CM10 till now. I will try again soon.
Confirmed to work on the Galaxy S 4G (SGH T595V) on the Unofficial CM9 Port. Much thanks bro!
WHoops, meant T959V
Hey , Can you tell me which Zip file you used. I want to clear out the old ones.
The July 29th one is the one that worked for me
Thanks! I used FBSync CM9 2012-06-29 0510 – June 29, 2012, on Maclaw Studio’s CM9 Beta 10 on Samsung Galaxy Ace. Worked great!
hey i m using AOKP Milestone 6 with Samsung Galaxy S GT-I9003
i m unable to file for my rom
The AOKP file should work for all the phones. If it doesn’t like in some rare cases ( It was rare till the last time i updated. ) , i can’t do it for all the phones. No time mate. Sorry.
. Too many phones out there .
I’m running an unofficial CM10 build for the S4 HTC One X (a ROM you don’t support), and am trying to modify the ContactProviders.apk myself. After disassembling its classes.dex with baksmali, I found no ‘res’ directory in the ‘out’ directory. I found that when I tried to do the same with the ContactProviders.apk found in the CM9 zip, there was also no ‘res’ dir.
Is there some flag I have to use with baksmali? Am I not supposed to use baksmali to disassemble the dex file?
Simpler steps:
1) Get AutoAPKTool ( Google for it. It will be there in xDA.
2) Load the framework-res.apk ( Option 1)
3) Decompile ContactsProvider.apk ( Option 6 )
4) Recompile & Build ( Option 9 ) .
5) Use the APK from Zipaligned folder.
6) Replace the APK in the zip file with this new one ( one of the zip files from my site)
7) Flash it.
Worked perfectly. Thank you.
Thanx for a great job!!
AT&T One X running aokp 6.2. I used the aokp manual build: FBSync ManualBuild AOKP 2012-08-01 and it’s working fine. Thanks!
Installed “FBSync AOKP 2012-08-01 0742 August 1, 2012″ on my Resurrection Remix ics v2.6.1 ROM, using CWM, removed and added the FB account – works great!
Thanks!
genious!
Thank you it worked perfectly on my first try!!
beautiful man! its working like a charm on SGS (GT i9000) with the CM9 stable.
downloaded the CWM went through the install, added new FB account and EVERYTHING is as it used to be on Gingerbread!!!
THANK YOU!!!!