This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Project setup
Tom Clement Oketch edited this page May 15, 2014
·
64 revisions
This page is only for setting up development environment for Mobile App . If you are looking for Web app Source Code & Details go here
- Mobile App Source Code available here.
The project was developed with IntelliJ IDEA v11 Community Edition, though Eclipse will work just as well.
Testing was done using emulators with Android OS v2.2 and above. We want to keep trying to use Android v2.2 and above as the main testing devices and target OS version since these will very likely be what will be used in the field.
- RapidFTR Android is a maven project. It consists of two modules by names RapidFTR-Android and RapidFTR-AndroidTests.
- RapidFTR-Android maven module have the source code along with the the unit test code. Unit tests are written with the help of Robolectric.
- RapidFTR-AndroidTests have the integration tests written in Robotium
- 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'
- Entering 'android' command in your terminal will launch the Android SDK Manager. We will use the SDK Manager to install the appropriate Android Platform version. Since we want to support a wide varierty of Android phones, we will compile and build with 2.2 version (API Version 8) of Android. Install version 2.2 from the SDK manager GUI.
- Create an AVD (from within the SDK Manager) with the size 240320. The lease resolution we would be using is 240320, so, testing for that resolution will help.
- Mac ships Java 1.6 by default(/System/Library/Java/JavaVirtualMachines/1.6.0.jdk) as well as maven. We faced some issues with Java 1.7 so set your $JAVA_HOME to the path above.
- To get started clean remove $HOME/.m2 folder (if it exists on your machine).
- Then install android-sdk with brew (brew install android-sdk)
- Add "export ANDROID_HOME=/usr/local/opt/android-sdk" to your .bashrc or.zshrc file.
- Open a new terminal and type android
- See the attached screenshot of android packages screen. Make sure you install packages that are shown here.
- Once you install everything then from menu bar choose "Tools" --> "Manage AVDs"
- Add a new minimalist avd (check the screenshot attached)
- Once added close everything and go back to terminal then type "emulator -avd x"(Note: x is the avd name used in screenshot, change it to whatever you want it to be). The command should start an emulator, give it a minute to start completely.
- Type "adb devices" this should start daemon server if it hasn't already and then display list of devices. You should see something like this displayed "emulator-5554 device". If it says "emulator-5554 offline" wait for a minute and try again. If the device refuse to come online then kill the emulator and start it again, give it few minutes and try this command "adb kill-server && adb devices"
- Once the device is up, navigate to your RapidFTR---Android code base and simply run "mvn clean install" It will install all maven packages and run all the unit tests and integration test. If everything passes or even runs completely with failing tests then you are good to go for development with a text editor.
- NOTE: If on running 'mvn clean install' you get the error 'command not found: mvn', that means maven is not installed. You can install it by running 'brew install maven'
Click here to see AVD Setup screenshot
- Click File -> Open Project and select the pom file, and the Maven project will be automatically imported.
- 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.
- From IntelliJ Preferences -> Plugins, install the Lombok Plugin. We are using Project Lombok to generate helper methods (like getters, setters, etc)
- To run the tests in IntelliJ edit the default JUnit run configuration and amend the working directory to point to ...../RapidFTR---Android/RapidFTR-Android (by default it will just point to ...../RapidFTR---Android )
- If you get any error related to maven, then click on Preferences => Maven then specify the Maven home directory: to the path of the maven home (In Mac OSX its /usr/share/maven.)
- If you get an error saying "ANDROID_HOME" not found, go to IntelliJ Preferences > Path Variables, and add an entry for ANDROID_HOME. The ANDROID_HOME points to the "sdk" folder in your Android SDK.
- If you get compilation errors related to getters, setters, etc - it could be a Lombok configuration issue. Go to IntelliJ Preferences -> Compiler -> Java Compiler and append "-classpath <path-to-your-lombok.jar>" to the Additional Command Line parameters. You may also need to un-check "Enable annotation processing" under Compiler -> Annotation Processors as well.
- Delete any old IDEA project config files from the codebase. You can do this by going to the
RapidFTR---Android
folder in command prompt and rungit clean -f -x -d
- In IntelliJ IDEA 12, select
Import Project
, select thepom.xml
file in theRapidFTR---Android
folder. CheckSearch for projects recursively
andImport Maven projects automatically
. ClickNext -> Next -> Next
. In thePlease select project SDK
dialog, click the+
icon, choose the Android SDK folder, and then selectAndroid 2.2
as the build target. Finish the import - Go to
IntelliJ Preferences -> Compiler -> Annotation Processors -> Maven default annotation processors
, select theProcessor Path
radio button and in the text box enter full path to Lombok jar. - IntelliJ still has some bugs with Maven and Android. You again have to open
File -> Project Structure -> SDKs
, and in the right side you will find some Android SDKs listed. Click each of those, and in the right side you will find somejar
files in the classpath. In case they are not properly populated by IntelliJ, toggle theBuild target
from2.2 -> something else -> back to 2.2
just for IntelliJ to properly detect all the jar files in the Android SDK
- From commandline execute "android update project -p pathToRapidFTR---Android/RapidFTR-Android". This generates local.properties and proguard-project.txt
- Run "cat pathToRapidFTR---Android/RapidFTR-Android/local.properties | grep sdk.dir". This gives the sdk path (needed for the next step)
- Open IntelliJ File -> Other Settings -> Default Settings -> Maven -> Runner click "+" under "Properties" and add a new property with name "android.sdk.path" with the sdk path(from previous step) as value
- View ->Tool Windows -> Maven Projects. Expand RapidFTR Android Parent -> Lifecycle -> install. This downloads all dependencies and runs the test suite, make sure you have your emulator started from a terminal for the integration tests to run.
- Run -> Edit configurations -> (On the left pane) Defaults -> JUnit
- By default the working directory is set to your project path. Change this to point to pathToRapidFTR---Android/RapidFTR-Android
- When trying to build the project and you encounter "java: invalid flag: UTF-8", ensure that the field "Additional Command Line Parameters" under "Compiler > Java Compiler" is left blank.
- Download the Eclipse ADT plugin for android and also m2eclipse plugin
- Download Project Lombok and run the JAR file to install it in Eclipse
- Import the project as existing maven project. If eclipse is not able to run the app because of the heap issues then increase the heap memory in eclipse.ini. Here are some of the configurations recommended -XX:MaxPermSize=1536m -Xms1536m -Xmx1536m
- You can run all the tests from the android parent directory RapidFTR---Android by using the command mvn clean install. This will also generate the .apk files which could be installed on the mobile phones for testing.
- To run unit tests alone, navigate to RapidFTR-Android folder and then run mvn clean install. Same is the case with integration-tests, move to RapidFTR-AndroidTests and run mvn clean install.
- To run individual unit test from IntelliJ, go to the unit test and run it a junit test. You might get some error, If you get an error, edit the configuration and select the working folder as RapidFTR-Android sub folder instead of RapidFTR---Android main folder.
See RapidFTR Google Group post here on steps for creating AVD: Click Here
- Though ANT will work for us, as we are using good amount of external jar files, we need some kind of dependency management tool.
- Any dependency management tool helps project to be moved easily from one machine to the another and aids in easy setup of the IDE.(ex: maven handles the dependency and the build stuff) - IDE neutral.
- Dependency management will be provided by many tools including ivy, gradle etc,. But android-maven-plugin seems to be widely used and have very good active community(have many releases in the recent past).
- Android-maven-plugin in specific gives most of the phases of android development for free - apk, apklib, zip, align, unpack, deploy, deploy-dependencies, redeploy, undeploy, emulator-stop/start run, push and pull logs.
- Maven by default provides a standard release workflow - multiple profiles and patching up an existing library or stripping of some unnecessary classes out of jar(maven-shade-plugin)