Skip to content

Development

Dieter Adriaenssens edited this page Jan 6, 2018 · 68 revisions

Setting up the development environment

Get the source code

Build dependencies

  • Android SDK (API 23) -> Check the system requirements
  • Android Build tools (23.0.1)
  • Java (OpenJDK 7 or Oracle JDK 8)
  • Vagrant (>= 2.0)
  • VirtualBox (>= 5.2)
  • Maven (>= v3.1.1) or Gradle (1.10)
  • jUnit v4.8.2 (plugin installed from maven repo during build)
  • Robolectric v2.2 (plugin installed from maven repo during build)
  • Mockito v1.9.5 (plugin installed from maven repo during build)
  • used libraries :
    • Crouton v1.8.1, Apache 2.0 (installed from maven repo during build)
  • optional build tools :
    • cobertura-maven-plugin v2.5.2 (>= v2.6 throws an error in combination with Robolectric, see issue #144)
    • coveralls
    • checkstyle
    • javadoc

Deploy Android SDK to local maven repo

Only required when building with Maven!

This step only needs to be done once when installing the Android SDK for the first time, or when updating the SDK to a newer version.

Due to license issues, the Android API is not available in the central Maven repository. One of the solutions is to install the required Android API to your local Maven repo (usually located in ~/.m2/repository).

This script will install a tool to deploy the SDK and deploy the required version to the local Maven repo :

.utility/deploy-sdk-to-m2-repo.sh

  • The required Android SDK (see build dependencies for the correct version) should be installed before running this script.
  • ANDROID_HOME should be defined and point to the location of the Android SDK folder.

Build and test the code

build and test : mvn clean test or ./gradlew clean check

build and test with code coverage : mvn clean cobertura:cobertura

build, test and deploy to an Android device : mvn clean install android:deploy or ./gradlew installDebug

build, test and deploy to an Android device and run the app : mvn clean install android:deploy android:run

To disable Unit tests in maven, run with -DskipTests=true

Enable debug mode for an android device

Lookup vendor id and product id

ubuntu@ubuntu-xenial:~$ lsusb
Bus 001 Device 002: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)

In this example, vendor id is '18d1', product id is '4ee2'.

Add vendor id and product id to udev rules

in /etc/udev/rules.d/51-android.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="4ee2", GROUP="plugdev"

Add vendor id and product id to vagrant setup

To make the android device available in the vagrant environment :

in Vagrantfile

  config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--usb", "on"]
    v.customize ["modifyvm", :id, "--usbehci", "on"]
    v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'Google Inc. Nexus 4 (debug)', '--vendorid', '0x18d1', '--productid', '0x4ee2']
  end

Clone this wiki locally