Software developers only: how to build Evothings Viewer App

AlexanderG

Lawn robot freak and project co-founder
Teammitglied
Evothings Viewer App is a web browser with some integrated (Javascript) plugins for hardware access (Bluetooth BLE etc.). This article describes how to build the Evothings Viewer App for Android (or CGTek Viewer for iOS) from code using Ubuntu Linux 18.04.

NOTE: If you have difficulties to get 'EvothingsViewer' running on your phone etc., I have uploaded the same app (based on the public Evothings Viewer code), just under another name and for the latest Android devices (SDK) at Google Play: https://play.google.com/store/apps/details?id=de.grauonline.evothingsviewer
Maybe give it a try... Tip: if the App is crashing after installation/upgrade, delete the 'location permissions' in Android App settings and restart the App.

Evothings Viewer is based on Apache Cordova (https://cordova.apache.org/).

  1. Install Android SDK: https://developer.android.com/studio/install
    In Android Studio->SDK Manager, install Android SDK 27 and Android build tools

  2. Install OpenJDK 1.8 (Java8): sudo apt-get install -y openjdk-8-jdk
    Activate OpenJDK 1.8 (Java8) compiler: sudo update-alternatives --config javac

  3. Install NodeJS on your Ubuntu Linux computer (I'm using NodeJS 14.15.0 and NPM 6.14.8):
    sudo apt install nodejs
    or: https://nodejs.org/en/download

  4. Install Cordova using NodeJS module manager:
    sudo npm install -g cordova

    or a specific Cordova version (not recommended) with:
    sudo npm uninstall cordova -g
    sudo npm install -g cordova@8.0.0

  5. Verify Cordova is properly installed (should output version 8.0.0 or higher, I have tested it with 11.1.0):
    cordova -v

  6. Optional: verify SSH for Git is properly configured (if git is not working in the next step, add your SSH public key to Github):
    https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey

  7. Download 'Evothings Viewer code (for Android)':
    git clone git@github.com:evothings/evothings-viewer.git

    or 'CGTek Viewer (for iOS)':
    git clone https://github.com/sjrcgtek/cgtek-viewer

  8. Install missing NodeJS packages using NodeJS package manager:

    cd evothings-viewer

    (NOTE: if you get an error about config-plugin, edit file 'package.json' and correct the dependency import like this:
    "com.evothings.evothingsviewer.config-plugin": "file:config/config-plugin"
    ...and remove the line starting with "config-plugin": )

    npm install

    optional (if you get vulnerabilities): npm audit fix --force

    If you get an error like 'Using requireCordovaModule to load non-cordova module elementtree is not supported', edit file 'scripts/util.js' and replace the lines with 'requireCordovaModule('elementtree') like this: require('elementtree')

  9. Build using Cordova:

    cordova platform add android
    cordova build android


  10. Run it in phone emulator (you will have to install it in Android Studio before):
    cordova run --emulator

    or on a real device: cordova run android
    (you can list devices with 'adb devices', you have to enable developer mode on your phone - more details here: https://cordova.apache.org/docs/en/2.9.0/guide/getting-started/android/)

  11. To make a bundle for GooglePlay, first remove plugins:
    cordova plugin remove phonegap-plugin-barcodescanner
    cordova plugin remove com.unarin.cordova.beacon
    cordova plugin remove phonegap-nfc
    cordova plugin remove cordova-plugin-local-notification

  12. Modify the config.xml like this:
    <platform name="android">
    ......
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']" xmlns:android="http://schemas.android.com/apk/res/android">
    <activity android:exported="true"/>
    </edit-config>

    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:usesCleartextTraffic="true"/>
    </edit-config>

  13. Finally make a bundle and sign it like this:

    cordova build android --prod --release
    cd platforms/android && ./gradlew bundle && cd ../..
    APP=platforms/android/app/build/outputs/bundle/release/app.aab
    jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore ../keys/evothings.jks $APP evothings
    jarsigner -verify -verbose $APP
    zipalign -v 4 $APP ./EvothingsViewer.apk

  14. Tip: If the App crashes, you can activate Android developer mode and then find a new menu item 'generate crash report' on your phone (Android settings->System->Developer Options->Generate crash report) (https://academy.test.io/en/articles/2541912-crash-logs-on-mobile-devices#h_7b23c4a3aa, https://www.browserstack.com/guide/how-to-get-android-app-crash-logs, https://support.kaspersky.com/de/common/diagnostics/13048)
 
Zuletzt bearbeitet:
Oben