Skip to content

Building and Deployment

DanNglk edited this page Feb 14, 2017 · 1 revision

Building

PegelAlarm is an Android App implemented in Java. In order to build the App you need the Android SDK. The easiest way to install the basic Android SDK and build tools is to download the newest version of Android Studio. You can follow and read the official install instructions at https://developer.android.com/studio/install.html.

PegelAlarm requires Android build tools 22.0.1 and is build for Android API 22. There are several ways to install both. You can open Android Studio and install both packages via SDKManager or just use the following commands on your command line:

~/Android/Sdk/tools/bin/sdkmanager “platforms;android-22”
~/Android/Sdk/tools/bin/sdkmanager “build-tools;22.0.1”

Now you can easily build the App via Gradle wrapper. The following command will build the project and produces an APK file for your Android platform at app/build/outputs/apk:

./gradlew build

Deployment

Deploying PegelAlarm is more complicated. First you need some Google API services. To do so you need to create a new project at https://console.developers.google.com and enable the following services in the "Libraries" tab:

  • Google Cloud Messaging
  • Google+ API

To use these kind of services you need credentials. Go to the "Credentials" tab and create two new OAuth2 credentials:

  • New OAuth2 web client for backend authentication
  • New OAuth2 Android client for App authentication

It is important to keep in mind that PegelAlarm is depending on two external services - Open Data Service (ODS) and Complex Event Processing Service (CEPS). At some point you need a running instance for both of these services to get PegelAlarm working. Take a look at ODS and CEPS to understand how to setup and deploy running instances.

Now we can create a new configuration file to set up PegelAlarm. Therefore, you need to create a new file config.xml inside app/src/main/res/values containing the following template:

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <string name="google_project_id">xxxxxxxxxx</string>
   <string name="google_oauth_web_client_id">xxxxxxxxxx</string>
   <string name="ods_base_url">http://127.0.0.1:8080/ods/api/v1</string>
   <string name="ceps_base_url">http://127.0.0.1:8082/ceps/api/v1</string>
   <string name="google_analytics_property_id"></string>
</resources>
  • google_project_id contains the projects id (look up at Google developer console)
  • google_oauth_web_client_id contains the new created OAuth2 web client id
  • ods_base_url contains base URL to running instance of ODS
  • ceps_base_url contains base URL to running instance of CEPS
  • (Optional) google_analytics_property_id contains Google analytics id

Now you can rebuild the project and install the generated APK file on your Android device. The following commands will build the project and installs the App on your connected device:

./gradlew clean build
adb install app/build/outputs/apk/app-debug.apk

Another way is to just copy the APK file to your device and install it directly via Android.


IMPORTANT

Before you start the App on your Android device, there are still a few things left to do. PegelAlarm expects some data from ODS and CEPS. Up to this Point there are no data sources configured in ODS, as well as no adapters in CEPS. Without these PegelAlarm will not work and crashes at some point. There are two Python scripts inside bin/ helping you to setup ODS and CESP in an easy way. Just run both scripts in following order:

./ods_pegelalarm_setup.py <base_url_to_ods>
./ceps_pegelalarm_setup.py <base_url_to_ceps>

This will create the necessary data that will get PegelAlarm to work. After running both scripts you are good to go and run the App on your Android device.

Clone this wiki locally