Skip to content

Development

Dieter Adriaenssens edited this page Jan 16, 2021 · 68 revisions

Setting up the development environment

Get the source code

Build dependencies

  • Android SDK (API 30) -> Check the system requirements
  • Android Build tools (v30.0.3)
  • Java (OpenJDK 8 or Oracle JDK 8)
  • for the Vagrant-based build environment :
  • Gradle (v4.6), with Android for Gradle plugin (v3.2.1)
  • 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

Setup the Vagrant build environment

Create/start the Vagrant box

In the root of the getback_gps project :

vagrant up

The first time 'vagrant up' is started, the vagrant box is created. This can take several minutes, depending on your speed of your internet connection and the speed of your machine.

Every other time, 'vagrant up' launches the already provisioned Virtual box.

Connect to the Vagrant box

After starting the Vagrant box (with 'vagrant up'), you can login to the Vagrant VirtualBox. From the root of the getback_gps project :

23:12 $ vagrant ssh
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-141-generic x86_64)

vagrant@ubuntu-xenial:~$ cd /vagrant/
vagrant@ubuntu-xenial:/vagrant$

The getback_gps project folder is mounted in /vagrant folder inside the Vagrant Virtualbox.

Build and test the code

build and test : ./gradlew clean assemble

build and test with code coverage : mvn clean cobertura:cobertura (maven was removed, still needs to be ported to gradle)

build, test and deploy to an Android device : ./gradlew installDebug

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 provisioning/files/51-android.rules

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

and run vagrant provision to install the 51-android.rules file to /etc/udev/rules.d/

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, "--usbxhci", "on"]
    v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'Google Inc. Nexus 4 (debug)', '--vendorid', '0x18d1', '--productid', '0x4ee2']
  end

Enable PTP transfer mode

On the Android device, enable Debug mode and PTP transfer mode.

Debugging adb connections

More info in : https://stackoverflow.com/questions/25614067/android-studio-recognizes-physical-device-as-null

List connected android devices

vagrant@ubuntu-xenial:/vagrant$ adb devices -l
List of devices attached
ZY224J75HS             device usb:2-1 product:payton model:moto_x4 device:payton transport_id:1
Clone this wiki locally