Skip to content

Setup for Android app

msporna edited this page Jan 8, 2019 · 4 revisions

This page lists steps required to make LAVA work with Android (Java).

  1. Do the initial setup: https://github.com/msporna/LAVA-test-coverage/wiki/Initial-setup or skip if done already
  2. copy 'lava' folder from LAVA project root/helpers/android_helper into your project's src
    • open 'LavaCoverageHelper.java' and:
      • replace [YOUR PACKAGE NAME HERE] with your package name
      • set your LAVA host name in '_LavaUrl' variable
  3. Open client/config.json and update required fields:
source_root_absolute_path: [absolute path to /src folder of Android project]
android_lava_helper_namespace: [namespace pointing to Lava Helper's 'lava' folder within your project - used to import LavaHelper into other classes]
INJECT_MODE: "android"

All paths must be absolute. For config details go to config.json-explained page.

  1. start LAVA server from /server folder by executing the following command manually:
python instrument_server.py

or if you are on Windows you can simply run:

run_api_windows.bat
  1. go to /client folder and from your terminal run python instrument_client.py and pass config.json path as command line argument so the command becomes: python instrument_client.py config.json

  2. the process of injecting probes will start

  3. check your project's source files, should be appended by instrumentation code

  4. your Android project is ready for getting the coverage - don't forget to build your app (it will be built along with injected probes code lines)

related example: https://github.com/msporna/LAVA-test-coverage/tree/master/examples/android_demo