Code This

std::cout <<me.ramble() <<std::endl;

Archive for September 2011

Building K-9 Mail With Exchange ActiveSync Support

with 34 comments

I have blogged in the past about the less than fortunate state of Exchange support in K-9. This is due to the fact that K-9 communicates with Exchange through and outdated and problematic protocol: WebDAV. WebDAV support is turned off by default in Exchange 2007, and completely removed in Exchange 2010. This of course implies that K-9 does not support Exchange 2010. Since I started working on K-9, I have had the desire to replace the use of WebDAV with the Exchange ActiveSync protocol, which is designed specifically for mobile devices. Unfortunately, this task was much too large for me to take on in my (non-existent) free time. Lucky for us Google sponsors the annual Summer of Code.

This year K-9 was granted 4 Summer of Code projects, including EAS support. The project was successful, and at this point we have “mostly working” EAS support in a branch of the K-9 repository on github. There are still a few small issues to work out, and a few small features to complete, but I currently use K-9 with EAS support for email on my phone. If you would like to build K-9 with EAS support for your own personal use, I am including step-by-step instructions for doing so (though as usual, I do assume some basic knowledge of source control and building java applications).

In order get the K-9 sources and complete a build, you will need a git client, a JDK, ant (you can also use eclipse, but I don’t include instructions for that), and the Android SDK (make sure it’s up to date). The first step is fetching the source:

git clone k9mail

This will clone the repository at into the directory k9mail. This fetches all branches in the K-9 repo, including the ms-eas branch where EAS support lives. The next step is to “checkout” the ms-eas branch:

git checkout -b ms-eas origin/ms-eas

This tells git to create a local branch named “ms-eas” that tracks the remote branch at origin/ms-eas, and switch to this new branch. Now you must build the K-9 source. First, create a file called ‘’ at the root of the source tree with the following entry:


Obviously, replace “/path/to/android-sdk” with the path to the Android SDK on your machine. The command to build is:

ant debug

This will build a signed and zipaligned installer ready for installation on your device. Finally, plug your phone into your PC via USB and ensure it is recognized by adb. To install the freshly built K-9:

adb install -r bin/K9-debug.apk

If you have K-9 installed from the market, you must uninstall it first. Your new K-9 will be signed with a different key than the market version and Android will not let you install this new version if the keys don’t match. Alternatively, you can give the app a new name in AndroidManifest.xml, but that’s outside the scope of this blog post.

If you want to report issues, feel free to mail k-9-dev [at]


Written by Kris Wong

September 29, 2011 at 3:29 pm