BuildingK9 - tmatz/k-9 GitHub Wiki

#How to build K-9 Mail

Introduction

K-9 Mail targets Java 1.5 (but we're using Java 1.6 @Override annotations, so a Java 1.6 compiler is needed).

K-9 Mail runs on Android 2.1 and newer versions. Currently SDK 4.0.3 (API 15) is needed to build the code.

Building with ant

To build

  • android update project --path . --subprojects --target android-17
  • android update lib-project -p plugins/Android-PullToRefresh/library/ --target android-17
  • ant debug

To install on your simulator or local device

adb install -r bin/K9-debug.apk

To build and sign the project for upload to the marketplace (project owner)

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/

  1. ant bump-version or ant -Dversion-name=4.200 bump-version: this will tag and push to origin
  2. ant clean release
  3. Test on actual device hardware
  4. ant upload: this puts it on google code.
  5. Upload to the market

Building with Eclipse

You'll need Eclipse with the Android Development Tools plugin installed. Follow the full directions found here: http://developer.android.com/sdk/eclipse-adt.html#installing. Make sure your Android SDK and ADT plugin are both up to date.

Building K-9 can take up to 1 GB of memory. You have to allow Eclipse to use this amount of memory or you will get out-of-memory errors when the Android compilers are run. In order to do this, edit your eclipse.ini file and make sure the following arguments are present: -vmargs -Xms128m -Xmx1024m

You can also pass these parameters to Eclipse on the command line.

To set up Eclipse to build K-9 Mail we need five projects. The first one is the ActionBarSherlock project, the second one is Android-PullToRefresh, the third one is ckChangeLog, the fourth one is HoloColorPicker, and the last one is K-9 Mail. We'll set them up in that order too:

  1. Open Eclipse
  2. Choose File->New->Project
  3. Choose Android Project
  4. Select Create project from existing source and then browse to PROJECTFOLDER/plugins/ActionBarSherlock/library folder.
  5. Finish the wizard, then right click on the newly created project in the Package Explorer and select 'properties'.
  6. Under the Android options, you see a section 'Library' with a checkbox IsLibrary. Make sure that's checked.
  7. Select 'library', choose File->Rename, and rename it to ActionBarSherlock.
  8. Clean and build the ActionBarSherlock project.
  9. Choose File->New->Project
  10. Choose Android Project
  11. Select Create project from existing source and then browse to PROJECTFOLDER/plugins/Android-PullToRefresh library folder.
  12. Finish the wizard, then right click on the newly created project in the Package Explorer and select 'properties'.
  13. Under the Android options, you see a section 'Library' with a checkbox IsLibrary. Make sure that's checked.
  14. Select 'library', choose File->Rename, and rename it to Android-PullToRefresh.
  15. Clean and build the Android-PullToRefresh project.
  16. Choose File->New->Project
  17. Choose Android Project
  18. Select Create project from existing source and then browse to PROJECTFOLDER/plugins/ckChangeLog/library folder.
  19. Finish the wizard, then right click on the newly created project in the Package Explorer and select 'properties'.
  20. Under the Android options, you see a section 'Library' with a checkbox IsLibrary. Make sure that's checked.
  21. Select 'library', choose File->Rename, and rename it to ckChangeLog.
  22. Clean and build the ckChangeLog project.
  23. Choose File->New->Project
  24. Choose Android Project
  25. Select Create project from existing source and then browse to PROJECTFOLDER/plugins/HoloColorPicker folder
  26. Finish the wizard, then right click on the newly created project in the Package Explorer and select 'properties'.
  27. Under the Android options, you see a section 'Library' with a checkbox IsLibrary. Make sure that's checked.
  28. Clean and build the HoloColorPicker project.
  29. Inside your PROJECTFOLDER, make sure you have a directory named 'gen'
  30. From Eclipse, File > Import
  31. Under General, select 'Existing Projects into Workspace' and click Next
  32. Next to 'Select root directory', Browse to your K-9 working copy
  33. Click Finish
  34. In the Package Explorer, right click 'k9mail' and click 'Properties'
  35. Select 'Android' again and then click 'Add'.
  36. Now add the previously created library projects to this project.
  37. Select 'Java Compiler'
  38. Check 'Enable project specific settings'
  39. Set the 'Compiler compliance level' to 1.6
  40. Click OK

You should now be able to build the project. If it had been built previously, make sure you clean it first. If you get errors about missing translation information for some locales, go to Project -> Properties -> Android Lint Settings and change the severity of MissingTranslations to Warning.

To install on your simulator or local device

Go to Run->Run Configurations, click Android Application then click the "new" icon (sheet with plus sign). Change the name to your liking, then click the brows button and select the K9 project. Click OK.

On subsequent runs, you can click Run->Run History and then click the name of your Run Configuration.

Building with IntelliJ IDEA

These instructions are for IDEA 12, but K-9 has successfully compiled under IDEA 9, 10, and 11 in the past.

  1. Checkout K9's source from GitHub.
  2. Open k9mail.ipr in IntelliJ.
  3. You'll get a green dialog in the top right corner asking you to import the Maven POM for ActionBarSherlock and Android-PullToRefresh -- select auto-import.

If you've never done Android development in IntelliJ before, you'll need to add your Android SDK to IntelliJ.

  1. Go to SDKs under Platform Settings
  2. Click the + on top to add a new platform and select Android SDK.
  3. Specify the path to your SDK root. You don't need to navigate to the specific platform you want; just the root is fine.
  4. Select your preferred 1.6 or 1.7 JDK. If you're on 64bit Windows, it's still recommended you select a 32bit SDK, since some of the Android toolchain is still 32 bit.
  5. Select Android 4.1.2 or higher as your platform. This is android-16, the minimum platform we require.

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.

Running your project

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.