Uncategorized

Syncing Kontact with Android

I recently became the proud new owner of an Android phone, or more specifically the Samsung Galaxy S i9000. Upon purchase it was promptly rooted and had a custom rom flashed onto it. Also recently KDE 4.6 was released and after a night of compiling I was sitting at a sparkling new desktop and customising it.

But this post isn’t about KDE 4.6 and nor is it about roms and galaxys. It’s about Kontact 2, part of KDEPIM 4.6 (which is still considered unstable by upstream) and how to achieve the state of PIM-zen which everybody should achieve once in their lives. The state of PIM-zen, for those too lazy to click, is the state where your PIM data (calendar/todo/contacts/feeds/etc) is accessible through any digital medium, be it your desktop’s PIM applications, a website visited from a remote location, or your mobile phone’s bundled PIM-suite.

Syncing your Calendar and events

I’m not going to talk about syncing email, as that has been covered countless times elsewhere. So let’s start with syncing the calendar, as it is the next most prevalent in use. Google phones unsurprisingly sync well to Google accounts – and given that Google accounts have a web-based frontend too, this kills two birds with one stone in our “access everywhere” requirement of PIM-zen. So our solution is going to be Kontact 2 <–Sync–> Google’s PIM Suite <–Sync–> Android device.

Kontact 2 is completely Akonadi based. In comparison to Kontact 1, where there was a makeshift Akonadi-resource wrapper which you could add to harness Akonadi as a data source, Kontact 2 only uses Akonadi-supported sources for your data. Luckily Akonadi makes it easy to connect to data sources, and so there is a specialised Akonadi-GCal-resource which you can add.

To do this, just right click on the bottom left box in Korganizer which holds the calendar sources, click “Add Calendar”, and select “Akonadi Google Calendar Resource”.

To get the resource, you may need to install the akonadi-googledata package. After clicking OK, all that remains is that you enter in your Google username (your email), and your Google account password. It should then start syncing and working flawlessly. Your Android phone can then sync to your Google account’s calendar.

However GCal is very buggy it seems as it isn’t unlikely that you’ll be having problems such as unable to authenticate or unable to grab calendar data. After scouring the web here are a few potential solutions to problems you might have:

  • Add the resource through the Akonadi configuration, not through Korganizer’s Akonadi wizard.
  • Ensure you have suffixed @gmail.com (even if you have an @googlemail.com address) to your username.
  • Make sure you don’t use special characters (non-alphanumeric) in your password.
  • Use the latest version of libgcal (>0.9.3 should be good enough)
  • Remove any older version of libgcal.
  • If you are behind a proxy, set it properly in KDE’s system settings -> Network -> Proxy, if not, ensure it is “Connect to internet directly”. (OpenSuse’s defaults to using env variables)
  • Ensure you have ca-certificates package installed, and the certificate from https://l.google.com/ to the list of accepted certs.
  • Have at least one event in the Google Calendar or it won’t sync (bug).
  • Sign out all other account sessions as detailed here.
  • … and of course, make sure Akonadi is running. (akonadictl start)

If it doesn’t work, you may want to stop akonadiserver, then start it with akonadictl start &> log in order to get a logfile. You can then poke around to see exactly where it failed. #akonadi on freenode may be able to help.

If it still doesn’t work, don’t despair (it didn’t work for me either!), as there is an alternative sync. The alternative uses CalDAV, as opposed to directly using Google’s Data API. To use it, just select “DAV groupware resource” from the wizard from the same screenshot shown above. However when it asks for you to pick the groupware server, click Cancel. This will prompt you to enter the details manually. Now follow the instructions by Google for SunBird for setting up a CalDAV resource, and as shown below in the screenshot, then after pressing OK things should starting syncing fine.

Finally, we should note that there might be some data loss, as Google Calendar doesn’t implement all of the data fields, such as attendees to events. Another thing you might want to note is that exporting your existing KOrganizer calendar into ical/ics and then importing into Google Calendar may not work, as KOrganizer doesn’t follow the ical/ics specs properly. If you are exporting and are manually modifying the ical/ics file such that it works, ensure you define the timezone, otherwise chaos will ensue :D

Syncing your contacts

Android has, just like Calendar, a built-in autosync with your Google account’s contacts. Akonadi also has a Google Contacts resource, which you may use in similar fashion to the Google Calendar resource described above. Unfortunately it doesn’t work with me, and so I’m currently in the process of debugging it with Savago in #akonadi. YMMV, and I don’t know any good alternative to syncing this.

Syncing your todo lists

This is a pain. First off it should be plainly stated that Google’s Android does not have a stock to-do application. Google’s own laughable implementation of a to-do webapp in GMail is – well, I would use the most derogatory adjectives I could think of to describe it, but that would just mislead you into thinking that it is possible to quantify the horribleness of it (which it isn’t) – oh, where was I? Oh yes, Google’s to-do webapp doesn’t allow you to access it via ical or any sane format, is missing a ton of useful meta-tags which some people might want, and so you should probably scratch out trying to sync over Google’s to-do webapp.

The options do you have are limited to what exists on the Android marketplace to read your todo lists. The two major ones are Astrid Tasks and RememberTheMilk, both of which are very good. Let’s cover RTM first.

The biggest downside with RTM is that in order to use the Android application for it (which is very good), you have to be a RTM Pro user, which costs 25$ a year, which is actually worth it if you are really dependent on task lists. Alternatively you could use their mobile barebones webapp which looks ugly but gets the job done. Their main webinterface is probably the only webinterface I actually really enjoy using, but the downside is that you cannot interact with your tasks via KTodo – you get only readonly access via an iCal file (note that you can also use a version where your todo items are converted to events in your iCal file for use through the KOrganizer interface). So the final setup goes somewhat like this RTM Android App <– Push/scheduled syncs –> RTM Website and/or Google Calendar <– Read-only iCal file –> KTodo. It should be noted that RTM supports syncing with your Google Calendar as well, so that’s an added plus if you want to use that interface. Note that there is also a RTM Plasmoid, which just adds icing to the cake.

The alternative is Astrid Tasks. Whilst interfacewise a little more clunky it still does get things done. It can sync with a “space” on the online saas Producteev, which in turn allows you to manage it from there. It also does a two-way sync with Google’s to-do webapp, but is known to be buggy, YMMV. However from there it doesn’t seem to have a way to sync with KTodo. Luckily, in a twisted sort of way, it does allow you to sync to RTM via a now unofficial sync (due to RTM’s policies of not allowing other companies to make added profit from their system), and using RTM you can then do the same sync as above. However if you use Astrid Tasks even with syncing to RTM, you don’t need to be a RTM Pro user and hence everything is free. Your options are therefore Astrid Tasks Android App <–> Producteev/Google, or Astrid Tasks Android App <–> RTM <– Read-only iCal file –> KTodo.

There is a third alternative – GTDAgenda. This webapp closely follows the original principles of Getting Things Done by David Allen. It’s a really powerful tool and comes with both a mobile site and Android application too. The only downside is that they are rather expensive and their free version is rather stripped down. Even when stripped down it does seem a little overkill for my needs, but it might be different for you.

My personal reccomendation is to just go with RTM.

Syncing your RSS feeds

Syncing your RSS feeds are a little tricky now that Akregator’s Google Reader sync is unmaintained and broken. Also Google doesn’t have a stock feeds application (why, oh why, Google, do you leave out the basics!) – update: actually it turns out they have recently published one. This pretty much limits you to running any Android app which syncs with Google Reader (there are a few out there, I personally use Pulse) – or you could just access Google Reader’s mobile application, which is really attractive for a mobile site I must say.

In the meantime, get somebody hacking on Akregator and fix that sync plugin!

… and reach your state of PIM-zen!

I hope that this guide has been helpful to those wanting to achieve that perfect sync across all their devices. Any tips and tricks I missed out please let me know in the comments.

Dion Moult

I've been developing software for well over 10 years, work as an architect (not the computer kind, the regular sort), and am classically trained as a pianist. I try to do the right thing when I get the chance in my field, such as through contributing to open-source communities and promoting sustainable living.

More Posts

Spread the love
Tagged: , , , , , ,

56 Comments

  1. A while ago i tried this with kontact 1 (using kde 4.5) and anakondi. i used to have an issue with syncing recurring appointments. Every time i put one in korganiser to sync with google calander it would screw up and no longer work properly. is syncing with recurring events still an issue?

  2. Thanks for this post.
    Just one question:
    If I have more than one calendar in my google calendar web app, it will sync every one?
    I just tryed yesterday and it seems to sync only the main one.

  3. tuxit, I have a few recurring events and I don’t have a problem, but I haven’t edited them in a while, perhaps editing them might provoke something and needs further testing.

    Samat, thanks for the information. I’ve updated the post accordingly. (I for one will stick with pulse though – as it has a great interface!)

    Andrea – yes, afaik it only syncs the main one. This is a problem on Google’s end and users have been shouting about it for a long time :(

  4. i’m syncing via google data api, and the events are added via google calendar website.
    They are correctly shown on my android phone,
    Just try to create an all-day event from web interface and see if it’s shown on kontact.
    For me, it does’nt work.
    Another thing: I have a “work” calendar and a “personal” calendar on my google calendar web interface. If I create an event in kontact, how can I choose which calendar to use?
    Thanks.

  5. Hey, I have the same phone as you and I’m thinking about the benefits of installing a custom ROM. Could you please tell me if, after installing the new image, the phone will send audio from a call into a standard set of jack headphones?
    The standard galaxy s will not route the audio like this unless you have a special headset connected, and I’m curious if a new image will change this.

  6. Hi, there’s an (admittedly rudimentary) TODO-App for Android provided by “Dato”. Name is “GTasks”. This syncs fine with my (not very much used) todo-list on Google Calendar.

  7. Andrea – change your default calendar on Google I think will fix it. Give me a moment to test the all-day events.

    metellius – I just used the standard jack headphones out of the box (or at least they look standard to me). Note that there are a whole collection of ROMs you can choose from (I am using Darky’s) so different ROMs will give you different results. Your question could be better answered in #xda-devs or #android on freenode.

    Jan – thanks for sharing that!

  8. “change your default calendar on Google I think will fix it”

    but i want to see ALL my calendar (actually 4) on kontact!
    and when creating an event on kontact I NEED to choose which calendar to use.
    My work stuff maybe will be shared with co-workers, my personal stuff will be shared with my wife… different tasks, different groups, different parts of my life.

  9. I created a patch for the akregator google reader. It can sync the list of feeds but is missing 2 things:
    – syncing the articles read / marked
    – storing the password in kwallet

  10. Akregator isn’t Akonadi based, is there any progress going on to port it? And also out of curiosity, which Kontact components use KHTML and which webkit and is there a plans to move completely to one or the other?

  11. Andrea – it’s just not possible unfortunately. There isn’t much we can do about it as the fault is on Google’s end. The only alternative is to host them on separate Google accounts.

    cph – awesome! However syncing the read/unread status is the most important imo. I hope you’re still working on it!

    hahoo – ask in #akonadi. Akregator is rather unmaintained at the moment which is a bit unfortunate. As for KHTML and Webkit, that depends what you have set in the Embedded tab in System Setting’s File Association – for html file types you have to choose which you want it to render with.

  12. some of you ever tryed mozilla prism?
    it’s about transforming a web app like gmail or calendar into a desktop application.
    I remember there was something similar but more kde-integtated.
    Or at least it’s under developement

  13. Is it not possible to sync with Android phones directly? I’m thinking of getting an Android phone but I’d rather not put all my private data on a Google server…

  14. I’m not saying it’s not possible. I’m just saying that Android phones sync well with Google accounts, and these are the methods for syncing across everything.

    Email IMAP/POP is all supported of course, so you don’t need to use GMail. With feeds you don’t have to use Google Reader but if you don’t you will lose any ability to sync read/unread status across multiple clients. With calendars, the built-in stock calendar application can sync with several accounts, not only Google’s, such as Micrisoft’s Exchange ActiveSync (good for companies), and Facebook’s – but of course we probably don’t use it. Third-party solutions are available to sync across individual ical files though if you are so inclined. With contacts, it’s similar to calendar in that it can also sync to Facebook, but it can also sync with other chat apps, for example WhatsApp. I’m not sure if it can sync CardDav directly, so you’ll have to research more about that yourself. And of course with Todo lists the preferred method is _not_ to leave it with Google anyways.

  15. Unless you meant syncing directly to the phone and not through the web, in which case I know you can treat the phone just as an external drive. Any other syncing, like contacts/calendar is done through the distributor’s own crappy program like Samsung Kies, which obviously is of no use to you (but any other phone would be the same).

  16. RTM ftw!

    After using Gmail for a few years now, I can safely say that Google Calendar and Gmail To-do are just BAD time-management tools.At least they don’t work for me, never had.

    However,I like the ’email’ aspect of Gmail for its simplicity and overall uncluttered look. Can there be any other webmail better than Gmail? (I know this is rather unrelated to the above post ;) )

  17. I have tested Google Akonadi resources here, and I can tell you: packages provided by distros suck hard. If you want Google Calendar to work, you need to recompile libgcal and akonadi-googledata against KDE PIM 4.6 and Akonadi 1.5 (the classic Gentoo™ solution for everything). Once I did that on a Kubuntu setup with non-working Google resources, Contacts and Calendar worked.

  18. p, yeah in general Google Calendar is rather terrible (nothing beats a desktop app), and to-do shouldn’t even be worth a mention. In general I also find that webmail interfaces are equally terrible to their desktop counterparts, but GMail’s interface is decent. I host my own email, so what I use probably isn’t an option for you, but if you are interested I am currently using the “Roundcube” interface.

    Emesto, I am on Gentoo but I can’t recall if when compiling kde pim 4.6 it prompted to recompile libgcal or akonadi-googledata. However I will re-emerge them tonight and see if that fixes my problems.

  19. just because you are talking about Gentoo (my distro too!) which version are you using? overlay or portage?

  20. Andrea – overlay.

    andrez – because I didn’t hear about it! I just took a peek at it and it looks like an _excellent_ alternative to using Google as the middle-man, especially because its android client allows you to specify your own server :) I’ve created an account on it and tested the Android Funambol sync, but I have yet to try syncing it to Kontact via Akunambol as it won’t compile on my machine (well, using live version, so yeah it’s expected). I’ll try to get it compiled and let you know how it goes!

  21. Well, I haave manged to install Funambol at my ArchLinux laptop. It is pretty easy to launch. The only problem is that Akunambol is not ready enough. At least I could not sync all my contacts – it allowed me to sync just part of them. So I exported contacts from Kontact to Thunderbird and it fed these contacts to Funambol server just right :)

    But with the next release of Akunambol I hope everything will work, at least basic PIM data sync. What I love about Funambol, though is that You can sync everything with anything. For example, after I fed him my Kontact stuff I now have all contacts in my Nokia N-72, which is Symbian phone :)

    Another thing – yeah, no middleman – everything can be done at your home box or even at laptop, since funambol is pretty light in terms of CPU/memory usage.

  22. Oh, you are running your own Funambol instance? I am using theirs for testing (but will consider running my own in the future of course).

    Can’t wait for Akunambol to mature! Then I won’t have to go through this annoying Google stuff.

  23. Very interesting… And funambol supports multiple calendars on Google calendar?
    I will try it and also kdepim from overlay :)

  24. I also got an Android phone this week, but I have no wish to give my data to G. Instead, I’m using Akonadi’s support for Kolab-based calendar and contacts – it just requires a folder for each on a plain IMAP server. I’m now sync’d between Kontact (4.4.10), Android, and Thunderbird on another machine. That’s nice!

    Steve

  25. Hi Dion et al,

    I found out about Kolab when somebody in a blog comment recommended it for syncing the N900, which I was thinking of getting. Nokia’s announcement made me opt for the HTC Desire Z instead.

    Info about Kolab can be found at http://www.kolab.org – it defines a standard for storing contacts and events/tasks in vcard/ical (v1) or XML (v2) format as email attachments, and these emails can be stored on a standard IMAP server. A full Kolab server offers more features too (see site).

    You’ll need to set up KMail to use a ‘Disconnected IMAP’ connection, so it retains a local copy of everything. Create some folders on the IMAP server called ‘Calendar’, ‘Contacts’ and ‘Tasks’ (or whatever names you prefer). Set it to check for mail automatically every x minutes.

    Use Akonadi to create a new address book on a Kolab server; I suggest using XML (v2) format. I think I set up my Calendar as a non-Akonadi resource (not at that machine right now); but I guess it should be possible via Akonadi too. I think Tasks needed a small amount of configuration too.

    I could drag/drop my contacts from one address book to the other. Don’t know if that’s possible with the calendar.

    On Android, you’ll need to got to Settings/Applications and enable installation from “Unknown sources”. Then, point the Android browser at http://code.google.com/p/kolab-android/downloads click on the newest ‘apk’ file to install it. You’ll need to configure IMAP server and folder settings. It syncs calendar and contacts, but not tasks. Oh yeah – turn off all the device’s Google sync options!

    For anyone wishing to hook up Thunderbird: get Mozilla’s ‘Lightning’ add-on first, then go to http://www.gargan.org/en/Mozilla_Extensions/SyncKolab and download the nightly release (there’s a sync bug in 1.5.1), then install the ‘xpi’ into Thunderbird’s add-ons. This one also syncs Tasks.

    FWIW: remember that any badly behaving client (including network problems while syncing) can screw up or delete the data on the IMAP server, so be paranoid and keep an offline copy! :-)

    Steve

  26. @andrea: there actually is a java app called gcalsync, which works for me with kontact. It is a bit of a pain to set up, but it supports multiple calendars and also offline use(as it’s syncing via an ical file)

  27. Steve, I just tried it out. Seems to work fine on the KontactKolab side but not too well on the KolabAndroid side. Times get added to what should be all-day events and the duration of all day events are extended by one day, and null and repeat contacts keep on being added to the remote end (ie, the kolab server) when syncing.

    Ideas?

  28. Hi,

    I’ve tried to reproduce the bug for all-day events but haven’t been able to. I have had a similar problem in Kontact with the German public holiday calendar – but this is not sync’d via Kolab.

    I’ve not have any contacts repeatedly added, but I have noticed that the Kolab/Android client will throw an exception (ie: crash) for formats it doesn’t understand.

    Steve

  29. Yeah I think the bug for all-day events is a problem with Kontact, which does not do timezones very well and can lead to screwy behavior. I have reported a bug on this and it has been confirmed, but nothing done about it.

    Yeah I’m experiencing a few contact problems, namely:
    – Contacts with only 1 name or >2 names instead of 2 names (First Last) will throw an exception.
    – null null contacts will be created on the remote end when syncing on Android
    – Strangely enough, if you keep on syncing, after a while no more null null contacts will be created, and syncing will work completely as expected. So if you’re fine with seeing a few blank contacts on your KAddressbook contacts, then that’s fine.

  30. I cannot but agree with the main article in terms of one’s quest towards PIM-zen, and the inability to reach it, reasonably, with Android, as best I understand it at the moment.

    My best read on this situation is that the problem seems to be two-fold: (1) korganizer, et al, is just broken – as noted; (2) google is just broken in terms of tasks – as is noted.

    Somehow, the rich functionality of the KDE 3 / Palm days, has just been lost over time. Inexplicably so. Well no – not inexplicably so. The nature of Palm, let alone Linux, means nobody is willing to pony up sufficient funds to refactor this very popular functionality.

    In the context of all of this, has anyone any thoughts or opinions with regard to pimlical? http://www.pimlicosoftware.com/

  31. Thanks for this great article ;)
    As explained here, I’d like to use the CalDAV protocol to sync my Google calendars. However, I can’t find the “DAV groupware resource” in akonadi.
    I have an up-to-date ArchLinux distro (x86_64) with KDE 4.6 and akonadi 1.5. I’m still using Kontact 1 but, since Kontact and akonadi are different projects, I don’t think this is the source of my problem.
    Does anybody know how I could get/add this DAV resource ?
    Thanks

  32. @Bill, even though now Korganizer could use a ton of work I do believe that the idea of Akonadi’s connectors is the right way forward. It has really allowed me to quickly and efficiently test out different PIM-zen solutions unlike any other standalone client. So for this regard (although Akonadi still have many buggy resources) I believe Akonadi should be applauded.

    Aside from tasks, the article does point out it _is_ possible to sync everything relatively nicely with Google services. Steve recommended using a Kolab server, and I can confirm that that also works really well (except now I need to find a web interface to complete the PIM-zen).

    @albinou: Although you are right that akonadi 1.5 is the latest version, you are wrong that Kontact 1 works like that – the difference between Kontact 1 and 2 as mentioned in the article, is that Kontact 1 uses a makeshift wrapper to add Akonadi functionality whereas Kontact 2 actually natively uses Akonadi to manage PIM resources. So it may very well be the source of your problem. Also, with Kontact 2, akonadi was moved to the kdepim-kresources package, so you’re after a different package. Hopefully that’ll provide the DAV resource.

    Also I noticed you mentioned “calendars”, keep in mind that Google’s DAV method will only sync your main Google calendar, and not the rest (Google’s fault).

  33. maybe it’s possible to sync the main calendar with Google’s DAV method and the secondary calendar with ical (readonly).
    It’s a workaround to see all the calendars hoping that the secondary ones are just… secondary.

    Just one question: maybe knotes can be synced with google tasks… there are a couple of (unofficial) android apps that syncs with google tasks so it’s possible (bi-directional way).

  34. Ok it’s all very simple, i have the solution for everything.
    Thunderbird can:
    1)use gmail via imap without problems. There is also an extension for a “gmail view” style of messages.
    2)use google contacts bi-directional way with this extension:https://addons.mozilla.org/it/thunderbird/addon/google-contacts/
    You can also choose to view just some groups or all. Example: my work laptop syncs only co-worker groups of my google contacts.
    3)use google calendar bi-directional way with these 2 extensions:
    lightning: https://addons.mozilla.org/it/thunderbird/addon/lightning/
    provider for google calendar: https://addons.mozilla.org/it/thunderbird/addon/provider-for-google-calendar/

    Zen reached? It seems YES.

  35. with thunderbird i have just one problem: if I archive mails in thunderbird they still remails in inbox in web interface… very strange…

  36. I just installed Kubuntu 11.04 and tried to get the google agents working. They work, but korganiser and kaddressbook are empty. To fix it, have a look on https://bugs.kde.org/show_bug.cgi?id=264861#c27

    But a question I have: In the nev Kubuntu, it seems that the GroupDAV resource agent as shown in your first screeshot is missing. Any ideas how to get/install it?

  37. The GroupDAV resources may be in a separate package just as the Google resources are used in a separate package. I recommend you ask in the kubuntu channel.

  38. Yes, I am expecting something like that, but I just can not figure out which one. I already installed a lot of packages which might be needed, but nope, no success.
    There is even a package called kdepim-groupware. Its description explicitly mentions egroupware, but it is still not shown in akonadi :(

  39. Thanks for the great post. I use the google akonadi resource with kontact (1) and its a great way to have a 2 way sync for both contacts and calendar on my android (also the GalaxyS).. Just wanted to know if u were also able to get mtp walking with the Galaxy S? Amarok detects it but am unable to access the song on the device or get it to sync

  40. Cheers bigbrovar. No, I haven’t tried to do any music syncing before. Amarok seems to be a bit of a beast on my system and takes up too many resources for me to enjoy it.

Leave a Reply

Your email address will not be published. Required fields are marked *