= Development Environment = [[TOC]] Eden Mobile is built on the [https://cordova.apache.org Apache Cordova] platform (sometimes known as Adobe !PhoneGap). 1. Cordova runs on '''NodeJS'''. If your OS distribution does not provide a NodeJS bundle, you can get one from here: - [https://nodejs.org/en/download https://nodejs.org/en/download] 2. Use the NodeJS package manager ''npm'' to install Cordova (9.0.0 currently): {{{ npm install -g cordova }}} See also: [https://cordova.apache.org/#getstarted https://cordova.apache.org/#getstarted] 3. If you want to build and test !EdenMobile, you also need - Java JDK - Ensure the bin is in your PATH, e.g. for Windows 10: * C:\Program Files\Java\jdk1.8.0_341\bin - Ensure that JAVA_HOME environment variable is set, e.g. for Windows 10: * C:\Program Files\Java\jdk1.8.0_341 - an SDK for the target platform, e.g.: [https://developer.android.com/studio/index.html#downloads Android SDK] - Configure as per https://cordova.apache.org/docs/en/latest/guide/platforms/android - Ensure the SDK tools are in your PATH, e.g. for Windows 10: * %USERPROFILE%\!AppData\local\android\sdk\build-tools\33.0.0 * %USERPROFILE%\!AppData\local\android\sdk\platform-tools - Ensure that ANDROID_HOME environment variable is set, e.g. for Windows 10: * %USERPROFILE%\!AppData\local\android\sdk 4. You can fork/clone !EdenMobile from here: - [https://github.com/sahana/eden_mobile https://github.com/sahana/eden_mobile] For some reason {{{sqlite-native-driver.jar}}} is not in the repo, so download from: * https://registry.npmjs.org/cordova-sqlite-storage-dependencies/-/cordova-sqlite-storage-dependencies-2.0.0.tgz & extract this to {{{plugins\cordova-sqlite-storage\node_modules\cordova-sqlite-storage-dependencies\libs}}} 5. Run the application - You cannot run in the 'browser' platform as it doesn't support the local database - It is easier to run on a real device than the emulator (to run on emulator you need to create an avd: {{{android avd}}}) - to run on a real device, you need to enable 'Developer Options' by tapping 7 times on the 'Build Number' in the About section (http://www.greenbot.com/article/2457986/how-to-enable-developer-options-on-your-android-phone-or-tablet.html) - open Chrome's Developer Tools panel (More Tools menu) & then open Remote Devices inside that (More | Remote Devices | Inspect) - Screenshots available here [wiki:DeveloperGuidelines/EdenMobile/Debugging#RemoteDebuggingonAndroidDevice Remote-Debugging on Android Device] - Windows users may need to enable Powershell script execution in order to be able to run Cordova: {{{ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser }}} - NB You may need to manually Clear Storage on the device after install (even for brand new installs) - NB Do NOT 'reconnect dev-tools' when reinstalling, close window & 'inspect' again, otherwise you will have lots of browser windows left open) {{{ cd eden_mobile npm install q-io cp default.config.xml config.xml # or .config.xml cordova platform add android cordova plugin add cordova-sqlite-storage # Reinstall needed for some reason (even though 'cordova plugin' shows it installed) # Needed on some platforms anyway, on others just to clear data, when-desired: adb uninstall org.sahanafoundation.eden_mobile # or org.sahanafoundation.eden_mobile. cordova run android # Builds apk & adb install platforms\android\build\outputs\apk\android-debug.apk }}} 6. Accessing your developer PC's version of Sahana Eden. Using Chrome Tools' Port Forwarding, you can redirect e.g. localhost:8000 on the Android device to localhost:8000 on your Developer PC when connected via USB. This allows you to use that in your Sync Settings. * https://developers.google.com/web/tools/chrome-devtools/remote-debugging/local-server 7. [http://jshint.com jshint] is a tool recommended to ensure Code Quality: {{{npm install -g jshint}}} Suggested .jshintrc attached (store in the folder just up from eden_mobile): * http://eden.sahanafoundation.org/attachment/wiki/DeveloperGuidelines/EdenMobile/DevelopmentEnvironment/.jshintrc 8. Some developers may have problems with settings being retained even when uninstalled due to cloud backup (https://developer.android.com/guide/topics/data/autobackup.html#EnablingAutoBackup), in which case adjust {{{platforms/Android/AndroidManifest.xml}}}: {{{