FaceBook Sync for Android ICS Devices [ Updated Aug 01 '12 ]

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.

Screenshot_2012-05-29-19-25-21                 Screenshot_2012-05-29-19-25-08

Update [Aug 1] : Files Updated.
Based on    MIUI 2.7.27   ,   CM9  2012-07-31  &    AOKP MileStone 6

Update ->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

  1. You should have ClockWorkMod ( CWM ) Recovery in your phone for doing it via Method#1.
  2. 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:

  1. Copy the appropriate ZIP file for your phone/ROM  to your SD card.
  2. Reboot your phone to recovery mode . You will need ClockWorkMod Recovery 3+ for this tweak to work.
  3. Go to ‘Mounts and Storage’.  Mount  ‘data’  (  and  ‘datadata’ if it is present ). This step is very important.
  4. Choose update from sdcard. Locate the ZIP file and update it.
  5. Reboot.
  6. Add FB account ( FB accounts which you had added before wont sync properly, so delete it and add again).
  7. Sync it.

Method#2  - Using Windows+ADB .


Files :  Download the corresponding file from below( Filenames have date  and ROM mentioned)

  1. Download the ‘FBSync_ADB_xx’ zip file  corresponding to your ROM.
  2. Extract it to a folder. For eg: to your desktop.
  3. Connect your phone in debug mode.  ( You can enable debugging mode from your phone Under Development > Enable Debugging mode ) .
  4. 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’
  5. 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:

  1. 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.
  2. For this , You have to edit the ContactsProvider.apk  and add the whitelisted permission.
  3. For editing the ContactsProvider.apk ( Which resides in the /system/app/ directory) ,You will need smali ( An assembler/disassembler for Android’s dex format ).
  4. 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>
  5. 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.
  6. Now , Since ICS , Android 4.0 , Google has disabled this provision of whitelisting applications natively , hence they have obfuscated certain fields from the database.
  7. Add the column named
    is_restricted

    to the raw_contacts table inside contacts2.db ( stored in /data/data/com.android.providers.contacts/database/ )

  8. 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';
  9. 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

Name Date
Name Date
ADB
FBSync ManualBuild ADB AOKP 2012-08-01 August 1, 2012
FBSync ManualBuild ADB CM9 2012-08-01 August 1, 2012
FBSync ManualBuild ADB MIUI 2012-08-01 August 1, 2012
FBSync ManualBuild ADB MIUI Galaxysmtd 2012-08-01 August 1, 2012
FBSync ADB AOKP 2012-06-28 0105 June 28, 2012
FBSync ADB AOKP 2012-08-01 0742 August 1, 2012
FBSync ADB CM9 2012-06-29 0510 June 29, 2012
FBSync ADB CM9 2012-08-01 0741 August 1, 2012
FBSync ADB Galaxysmtd MIUI 2012-08-01 0740 August 1, 2012
FBSync ADB MIUI 2012-06-28 0105 June 28, 2012
FBSync ADB MIUI 2012-08-01 0740 August 1, 2012
CWM
FBSync AOKP 2012-06-28 0105 June 28, 2012
FBSync AOKP 2012-08-01 0742 August 1, 2012
FBSync CM9 2012-06-29 0510 June 29, 2012
FBSync CM9 2012-08-01 0741 August 1, 2012
FBSync ManualBuild AOKP 2012-08-01 August 1, 2012
FBSync ManualBuild CM9 2012-08-01 August 1, 2012
FBSync ManualBuild MIUI 2012-08-01 August 1, 2012
FBSync ManualBuild MIUI Galaxysmtd 2012-08-01 August 1, 2012
FBSync MIUI 2012-06-28 0105 June 28, 2012
FBSync MIUI 2012-08-01 0740 August 1, 2012
FBSync MIUI Galaxysmtd 2012-08-01 0740 August 1, 2012

 

177 thoughts on “FaceBook Sync for Android ICS Devices [ Updated Aug 01 '12 ]”

      1. 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.

  1. Hi,

    Tried both automated and manual versions and not syncing even if the table is updated. Running AOKP M5.

    Thanks

    1. 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. ;-) .

      1. It wasn’t just the contacts, it was the home screen and completely unrelated apps. I’ll try giving it a little time.

        1. 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. :-) .

  2. 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.

    1. 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.

  3. 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.

    1. 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.

  4. 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!

  5. 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…)?

  6. 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.

  7. 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??

    1. 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.

  8. 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!

      1. 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.

    1. 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 . :).

          1. 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.

  9. Niranjan Thilak – YOU, my friend – are awesome!!

    CWM worked like a charm. EVO4G ROM=cm-9-20120706-UNOFFICIAL-supersonic.zip

    Thank you!!!

  10. 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!

  11. 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.

    1. 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)

  12. 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!

      1. Hi Niranjan. Could you make changes for CM10? I tried to do it manually but I was not lucky. I destroy the phone several times, jajajaja! If you perform an upgrade, I would be very grateful. Greetings.

  13. 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!

    1. 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 .

      1. i am using MIUI 2.10.19. n i am not able to find correct zip file… plz help.. i need it coz i dont want to go back to Real ICS.

  14. 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?

    1. 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.

      1. Hi Niranjan. I followed this cm10 instructions but getting “Unfortunately, the process android.process.acore has stopped.” Could you please make one for cm10? im on that (last nightly – october 14, 2012) and on i9000 (Galaxy S).

  15. 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!

  16. 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!

  17. 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!!!!

  18. hey niranjan! sorry i got those dump-ass-questions, but which one i have to take for cm-9.0.0-galaxysmtd stable on i9000? i had to reflash two times after FBSync ADB CM9 2012-06-29 0510 and FBSync ADB CM9 2012-08-01 0741 …thanks a lot!

  19. in CWM when I try to install zip I get back a “installation aborted” message without further details. I’m using CM9 stable

  20. Tried it on my G2/Desire Z with limited success. Running a modified version of AOKP for the Vision/DesireZ (Milestone 6). First attempt (with the CWM file) brought up the FB Contacts Sync dialog, but only contacts (but not pictures) were available. Second and third times trying (deleting the FB account, uninstalling and reinstalling the FB app itself) didn’t even sync the contacts. Any insight would be appreciated if you have it. Thanks! :)

  21. Hi i have a SGS (GT i9000) with the CM10 Nightly 4.1.1 Jelly bean.
    Tryed to downloaded the CWM file “FBSync CM9 2012-08-01 0741″ and went through the install!!! but when i reboot my phone i get the Error “android.process.acore” should i get another file?? or is there a fix??

  22. sorry for ignorance..
    but what is the difference between CWM CM9 0510 and 0741… could not figure out.. How do I know which one is the right one for my CM9 installation?

  23. Iam using Atrix with CM9 ,and iam tring to do the FB Contacts Sync but iam struck at Mount/data and what is the next step i want to do.

  24. I’m running cm9 2.6.38.8-everolv-acies-ics+ (build: aug 12 2012) on supersonic. Do I need specific updated file or can i run earlier version?

  25. Do you have a Facebook sync patch for jelly bean AOKP build5 ROM running on Samsung Vibrant. Will really appreciate it if you could come with a solution. Thanx

  26. Hi..
    I’m running CM9-2012-10-04-UNOFFICIAL-pico rom on my HTC Explorer…Can you tell me when will you be uploading the files for this rom?? OR can any of the provided files work for my version?
    Most of my contacts’ phone numbers are on fb…so I need it badly..

  27. First off, thanks for ALL of this information. I got it working, had to do take some different steps.

    I first tried putting my own edited ContactsProvider.apk into one of your installer zips. After some inspection, when it didn’t work, the sqlite script didn’t run. When I add the column myself, I noticed a difference between the command on this post and the command in the script [ie: 'INTEGER NOT NULL DEFAULT 0' vs 'VARCHAR']. Both commands execute [NOTE: I pulled the db file and did it on my desktop] just fine, but what’s the difference. Rather, why the change?

  28. nira first of all thank you for being so selfless and helping everyone out that takes a special person .. im running locked motorola electrify with the hybrid deblur lite rom which version should i download…here is where i got the rom xda developers[rom]]gb]hybrid(stock/cm7) multilingual deblur

  29. Thanks for this mod! I had problems with this even with the OTA update to ICS from HTC. With the CM9 mod, I had the same problem, but this did the trick:

    What I did:

    - Force stopped Facebook
    - Deleted all data
    - Uninstalled Facebook app (I am pretty sure this isn’t necessary, but better safe than sorry)
    - Uploaded mod to SD card
    - Rebooted in CWM Recovery
    - Mounted “data”
    - Updated from the zipped file
    - Rebooted phone
    - Reinstalled Facebook from Google Play
    - Entered account information
    - Synced all contacts!!!!

    I did this with a HTC Sensation (EU version – no Vodafone, T-Mobile specific version)

    Good luck to anyone trying this as well!

    Kasper

  30. I’m using CM9 ICS by Ivendor with SGS 9001, your mod is very usefull one, it sync my contact and all my faceebok contact appear in my people screen ,but they dont came together , i make it manuelly but this time the pictures are not change.

  31. Help! its syncing the contacts but the pictures are showing up very low resolution and blurry…any way to have Hi Res pics ?
    Im on Epic 4g CM9

  32. Hello, I was following your steps to enable contacts sync in CM10 for my Arc and I got stuck starting from step (5), where can I get that zipaligned folder ?? and which apk file ??
    and for step (6) can I use the contactsprovider.apk from (FBSync_ManualBuild_AOKP_2012-08-01) ?
    Would you please provide me with the detailed steps ??
    Thanks :)

    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.

  33. Hi,

    I am running AOKP JellyBean 4.1.2 on my HTC Sensation. I’m also facing the same problem when I try to sync manually from Account settings > Facebook. I have downloaded the flashable zip but I have one query. Will this work for my JellyBean ROM. I dont want to use any stupid application from the play store for this. I tried Contacts+ was also thinking of Haxsync. But now since there is a solution I would try this workaround.

  34. Can you update it to miui 3.6.21? I don’t know anything about android development to make it on my own…

  35. after step 3, i.e. decompiling, we added the arrays.xml with the above mentioned content in /res/values/

    How do you go about the field to be added in the table?
    I’m simply trying to do this for CM10.1

  36. Have you tried this with CM10.1?
    I was trying for it..
    unable to figure how to do the bit about adding the is_restricted field to the database!
    Could you look into that?

    1. download ashell and asqllite. give correct root permissions. browse through data>data>com.android.providers.contacts/database/contacts2.db open it and run a query ‘ALTER TABLE raw_contacts ADD COLUMN is_restricted VARCHAR’;

  37. I am using s3 international version. I installed miui rom on my mobile version is 3.6.21.. Its jelly bean it is showing android 4.1.1 . Is it possible to use the above zip file? Actually I tried it showed me aborted message. Can you please help me on this.

  38. This method works great even on latest 4.3 and is fairly simple. Thanks for this method Niranjan.
    Is there any way to sync regular fb calendar, thanks :)

  39. HI Niranjan,

    Your method still works great on 4.3 as well. 1 thing I was curious about is if we can somehow enable FB calendar in a similar manner.

    Thanks.

  40. Seems this method no longer works on Kitkat. Adding arrays.xml to ContactsProvider and recompiling the apk leads only to Contacts app FCs :(

Leave a Reply