Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Project setup

Subhas Dandapani edited this page Jul 4, 2014 · 64 revisions

We are currently targeting Android v2.3.6 because those are the devices that are currently used. However, this is going to change as we shall be supporting Android v4.0.x and above, since its getting very difficult to find 2.3.x devices in the first place.

We're slowly porting Activites and Beans to use the excellent Android Annotations library. So you'll find classes with an underscore, like RapidFtrApplication_, which are generated by AndroidAnnotations during compile time. We also heavily use Project Lombok to ease Java development.

Setup Pre-requisites

  • JDK 1.7
  • Maven 3.2 or above

Setup Android SDK

  • Download the android sdk from the android developers website and unzip the same. If you are on Mac, it is recommended to use homebrew to install Ex: 'brew install android'
  • Enter android sdk in your terminal to open the SDK manager, and install the following items:
    • Platform tools
    • Build tools
    • Extras > Android support library
    • Extras > Android maven repository
    • Android 2.3 API
    • Android 2.3 System Image for the emulator
  • Set ANDROID_HOME globally (Mac: /etc/launchd.conf, Linux: /etc/profile, Windows: System Properties)

Setup Android Emulator

  • Enter android avd to open the AVD (Emulator) manager
    • Create an AVD (from within the SDK Manager) with the following settings:
AVD Name: rapidftr
Device: 2.7" QVGA (240x320 ldpi)
Target: Android 2.3.3 - API Level 10
SD Card: 200 MB
(you can leave all other options as is)

The least resolution we would be using is 240*320, so, testing for that resolution will help.

  • Launch the created AVD
  • Performance Tip: As a faster alternative to using the android AVD, you can use Genymotion
  • Advanced Users: If you use the Intel Android images with HAXM, note that they don't work with VirtualBox. If you have VirtualBox VMs running, HAXM will cause problems!

Build from the Command Line

  • Run mvn clean package from the RapidFTR-Android folder to test whether everything is working properly. This will build the APK inside the target folder
  • Run mvn android:deploy android:run to deploy and run the generated APK to the emulator
  • NOTE: Running mvn -version should say clearly that its using JDK 1.7, and not the system JDK 1.6. A common problem with Macs is that while your shell uses latest JDK, Maven uses the old JDK. If this is the case, then either fix JAVA_HOME, or use JEnv with maven activated.

IDE setup

IntelliJ Idea 13 Community Edition

  • Simple import: File > Open Project and select RapidFTR-Android/pom.xml file, and the Maven project will be automatically imported. For more information on how to do this (http://www.jetbrains.com/idea/webhelp/importing-project-from-maven-model.html)
  • Intellij comes with default Android support, so once the project is loaded it asks for configuring the android framework. Go ahead and configure the framework.
  • Subsequent Steps:
    • Project SDK is Android with JDK 1.7 in File > Module settings
    • Install Lombok Plugin from IntelliJ Preferences > Plugins (necessary to make IntelliJ recognize Lombok's compiler annotations)
    • Navigate to target/generated-sources/annotations and make sure its added as a source folder (necessary to make IntelliJ recognize AndroidAnnotations)
  • Common Errors:
    • Set ANDROID_HOME in Preferences > Path Variables
    • Set Maven home folder in Preferences > Maven
    • Clean old hidden IntelliJ files and freshly open the project. Fixes most issues when core project files (pom.xml, IntelliJ upgrade) are changed. Make sure you have committed/stashed the changes you're doing, and then run git clean -f -x -d