K-9 Mail targets Java 1.5 (but we're using Java 1.6
@Override annotations, so a Java 1.6 compiler is needed).
The current development version of K-9 Mail runs on Android 4.0.3 (API level 15) and newer versions. Currently, SDK 19 is needed to build the code.
This document covers several alternatives for building K-9 Mail:
android update project --path . --subprojects --target android-19 ant debug
adb install -r bin/K9-debug.apk
You'll need a few new entries in your local.properties to upload to google code:
gcode-user=your-username gcode-pass=your-secret-token gcode-project=your project name on google code (defaults to k9mail)
You'll also need googlecode_upload.pl in your path from http://search.cpan.org/dist/Google-Code-Upload/
ant -Dversion-name=4.200 bump-version: this will tag and push to origin
ant clean release
ant upload: this puts it on google code.
You will need Eclipse with the Android Development Tools plugin installed. If you have not set this up already, then here is a good place that will get you started. Make sure your Android SDK and ADT plugin are both up to date. The following instructions were based on Eclipse Juno (4.2) and ADT Version 22.
You will also need to download the K-9 Mail source repository using Git.
As part of the setup, you will be creating 6 different K-9 Mail related projects inside Eclipse. Because it will be easier to adjust preferences for these projects if they are kept separate from any other projects, you should create a new workspace for use with K-9 Mail.
Start Eclipse. A dialog will likely pop up asking that you select a workspace. If that doesn't happen, then once Eclipse has started, use File -> Switch Workspace -> Other... to bring up the selection dialog. In the dialog, use the Browse button to navigate and make a new folder (somewhere outside of your K-9 Mail source tree) where the new workspace will reside. If Eclipse opens a Welcome window, simply close it to see the workspace windows behind it.
There are likely numerous tweaks to the workspace preferences that would be beneficial (for example, adjustments affecting code style), but for the moment, there are just a couple that should be reviewed:
Text file encoding
In the Eclipse menu, go to Window -> Preferences. In the dialog, expand the General category and select Workspace. Change the Text file encoding setting to UTF-8. Click Apply to save (the dialog remains open).
Compiler compliance level
In that same dialog, expand the Java category and select Compiler. Set the Compiler compliance level to 1.6. Click OK to save the settings and close the dialog.
(Note that the following procedure only works cleanly for K-9 Mail versions 4.503+. To build earlier versions, you will likely need to refer to an earlier edition of this document, such as here from April 3, 2013.)
In the Eclipse menu, go to File -> Import.... In the dialog, expand the Android category and select Existing Android Code Into Workspace. Click Next.
Use the Browse button to navigate to the top folder of the K-9 Mail source tree on your system and click OK. A set of 6 projects should automatically be found and selected for import into the workspace:
Click Finish. Eclipse will import the projects and immediately begin building them. You can go to Window -> Show View -> Progress to monitor its progress. Once everything is built, you can click on the Problems tab. You should see no errors and maybe 200+ warnings. This is typical.
If you have an official version of K-9 Mail already installed from either the Play Store or from the Downloads page, you must first uninstall it before you will be able to install your own version. You might want to export and save your settings before uninstalling.
To install and run the app, click on the k9mail project folder in the Project Explorer window, and then follow these general instructions.
You can also install and run the test package. Click on the k9mail-tests project folder in the Project Explorer window, and then follow these general instructions.
These instructions are for IDEA 12, but K-9 has successfully compiled under IDEA 9, 10, and 11 in the past.
If you've never done Android development in IntelliJ before, you'll need to add your Android SDK to IntelliJ.
To configure K-9 to use your new SDK, select Project under Project Settings, and choose your Android SDK under Project SDK. You'll need to do this even if you already have an Android SDK configured in IntelliJ since different projects can use different SDKs..
To execute the first build of your project, click on the build icon in the top menu (it looks like a 4-box square with an arrow in the top-left corner to the left of the K-9 dropdown). If it's successful, the Messages pane should pop up with only Information and Warning messages.
Click on the Play button to the right of the K-9 entry in the drop-down box. The default is to launch in an emulator. To launch on your device, click on the K-9 drop down, then Edit Configurations. Change the Target Device to either USB Device to always run on your device or Chooser Dialog to select on each launch.
Last edited by cketti,