Air Quality is a hybrid Cordova application for collecting measurements that is currently developed by Mapping for Change, and is supporting the GeoKey platform developed by Extreme Citizen Science research group at University College London.
- Homebrew installed
- Node installed
- Yarn installed
- Java Development Kit (JDK)
- Android Studio
Air Quality requires the geokey-airquality extension to be installed alongside GeoKey.
Install Homebrew using the official script:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You can install Node directly with Homebrew:
brew install node
However, it is recommended to use Node Version Manager to enable easy updating and switching between versions.
There are multiple ways to install Node Version Manager, please follow official guide.
After that, install Node itself:
nvm install node
Or if you wish to use long-term support (LTS) version:
nvm install node --lts
Since you already have Homebrew installed, you might just use it to install Yarn:
brew install yarn --without-node
Flag --without-node tells Yarn not to install Node alongside (since you should already have it on a system).
Install Java Development Kit (JDK) 8. Cordova also requires Gradle to be installed too (e.g. using Homebrew).
If by running java -version you see anything else than "1.8" or you get other Java errors, try to set the path to required version by including export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) in your ~/.bash_profile (don't forget to reload with source ~/.bash_profile).
Install Android Studio, then run the SDK Manager and install:
- SDK Platform for API 27
- latest Android SDK Platform-tools
- latest Android SDK Build-tools
Add the following exports to your ~/.bash_profile (also reload with source ~/.bash_profile).
export ANDROID_SDK=$HOME/Library/Android/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH
Check the requirements to make sure the system is up and ready by running yarn cordova requirements android.
Navigate to project's directory and install required dependencies:
yarn installCopy configuration file from the sample:
cp config.sample.js config.jsEdit application's configuration - add the URL of GeoKey platform used (without /api/), also client ID.
Build Angular application:
yarn gruntDownload all the required Cordova platforms:
yarn cordova platform add browser
yarn cordova platform add androidBuild Air Quality application for all platforms:
yarn cordova build --releaseOr individual platforms:
yarn cordova build --release browser
yarn cordova build --release androidGet the release key from Mapping for Change (including instructions), copy it to your working directory.
Sign the app (you will need to enter the build passphrase):
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore airquality-key.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk alias_nameLocate the zipalign tool (usually inside /path/to/Android/sdk/build-tools/<version>/zipalign) and run the following:
zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk air-quality.apkFor example, on macOS with Android SDK version 28.0.3, the command should be:
~/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk air-quality.apkThe finalised signed app (located at the root of the project) can then be uploaded to Google Play Store.
Please note, Cordova previously was adding additional "8" at the end of generated Android version code. This has changed in the later updates. Following the default settings, Google Play store will not allow to upload any new versions of the app, as they will all be treated as lower versions. A workaround was added, where Android version code must be explicitly set in the XML configuration file.
When building Angular application, use:
yarn grunt devChanges will be watched and applied when saving, all Cordova platforms will be recompiled also.
Don't forget to build Air Quality application:
yarn cordova buildWhen Air Quality application is compiled, you can run each of the platform:
Start a local server:
yarn startNow you can access Air Quality using the http://localhost:4060 URL from any browser on your local machine.
To run on an emulator:
yarn cordova run --emulatorRun emulator -list-avds to see all emulators you have created locally, emulator @<emulator> to run a specific emulator.
To run on an actual Android device, use:
yarn cordova run android --target=<device>Run ~/Library/Android/sdk/platform-tools/adb to see all available Android devices.
All tests are written in Jasmine.
Navigate to project's directory, build Angular application, then run:
yarn testYou can pass custom arguments too, for example, yarn test --no-single-run will continue running tests after a change is being made to the files (either app or tests).
Coverage report is generated inside the coverage directory.