Mobile App/Cordova Development Notes: Difference between revisions
No edit summary |
m (Teolemon moved page Mobile App/Development Notes to Mobile App/Cordova Development Notes) |
||
(One intermediate revision by the same user not shown) | |||
Line 183: | Line 183: | ||
== Publishing on App Stores == | == Publishing on App Stores == | ||
* See [[Mobile App/AppStores]] | * See [[Mobile App/AppStores]] | ||
== May be of interest for future apps == | == May be of interest for future apps == |
Latest revision as of 13:12, 2 May 2021
This page contains notes regarding the development of the Open Food Facts mobile apps (Cordova version).
Source code
The current Open Food Facts apps for iOS, Android and Windows Phone use Apache Cordova (previously known as Phonegap).
Installing Cordova on your machine
- Cordova: http://cordova.apache.org/
- Installing Cordova 3.6 : http://cordova.apache.org/docs/en/3.6.0/guide_overview_index.md.html
- http://cordova.apache.org/docs/en/3.6.0/guide_cli_index.md.html#The%20Command-Line%20Interface
- Following notes are for the Windows Platform, but most of it probably applies for Mac or Linux.
Installing Node.js
Install Node.js
- http://nodejs.org/
- Current Version: v0.10.32
Install Git client
Install Cordova
in git-bash client:
npm install -g cordova
cordova -v : 3.6.3-0.2.13
Use cordova platform to know which platform you can install.
cordova platform
Install your platforms
cordova platform add firefoxos cordova platform add android
Possible errors
"error android_home is not set and android command not in your path" when doing "cordova platform add android"
- Install Eclipse ADT (Note : for win8 32bit/64bit install 32bit ADT)
- Setup Environment Variables :
- Add to existing system variable "path" : <path to adt-bundle\sdk\tools>;<path to adt-bundle\sdk\platform-tools>
- http://docs.phonegap.com/en/edge/guide_platforms_android_index.md.html
- http://developer.android.com/sdk/index.html
- C:\Users\Stéphane\AppData\Roaming\npm;C:\Users\Stéphane\AppData\Local\Android\android-sdk\tools;C:\Users\Stéphane\AppData\Local\Android\android-sdk\tools;C:\Users\Stéphane\AppData\Local\Android\android-sdk\platform-tools
"error failed to run javac -version make sure"
Java JDK
- http://www.oracle.com/technetwork/java/javase/downloads/index.html
- JAVA_HOME : C:\Program Files\Java\jdk1.8.0_20
- add to PATH : C:\Program Files\Java\jdk1.8.0_20\bin
ANT
- http://ant.apache.org/manual/index.html
- set ANT_HOME
- add %ANT_HOME%/bin to path
"Error: Failed to run "java -version"
which java --> an old version of java in C:\Windows\System32 was causing the issue.. :-(
http://stackoverflow.com/questions/24493693/cordova-android-revision-to-low
Run SDK Manager, install Android build tools.
Get the source code
Clone the Open Food Facts Cordova repository
git clone https://github.com/openfoodfacts/cordova-app.git
iOS specific issues
Android specific issues
Android version code
in config.xml : http://stackoverflow.com/questions/23001780/how-to-get-cordova-3-4-0-to-set-android-version-name-code-on-build
Cordova plugins
Camera, File, File transfer plugins
Install the various plugins
cordova plugin add org.apache.cordova.camera cordova plugin add org.apache.cordova.file cordova plugin add org.apache.cordova.file-transfer
New names for plugins:
biz_000@Colibri MINGW64 ~/Desktop/cordova-app (master) $ cordova -v 6.4.0 biz_000@Colibri MINGW64 ~/Desktop/cordova-app (master) $ cordova plugins cordova-plugin-barcodescanner 0.7.0 "BarcodeScanner" cordova-plugin-camera 2.3.0 "Camera" cordova-plugin-compat 1.0.0 "Compat" cordova-plugin-file 4.3.0 "File" cordova-plugin-file-transfer 1.6.0 "File Transfer" cordova-plugin-whitelist 1.3.0 "Whitelist"
Barcode scanning plugin
You may also have to install Apache Cordova plugin for barcode scanning.
cordova plugin add com.phonegap.plugins.barcodescanner
Moodstocks
Install Moodstocks
Instructions not up to date for Cordova 3.6. This might be an up to date example :
public class Demo extends CordovaActivity { private boolean scanActivityStarted = false; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.init(); // Set by <content src="index.html" /> in config.xml super.loadUrl(Config.getStartUrl()); //super.loadUrl("file:///android_asset/www/index.html") }
Moodstocks Bugs
The following pops up on the 2nd scan with Moodstocks:
java.lang.RuntimeException : Unable to start activity ComponentInfo ... The specified child already has a parent. You must call removeView() on the child's parent first.
-> Problem with jQuerymobile not "exiting" properly from scan when clicking on "Back" ?
Moodstocks plugin tutorial
Firefox OS
See #firefoxos on Slack
A port of the app was initiated on Firefox OS. The main issues were with the barcode scanner and the lack of Cordova feature parity for the platform.
Notes from the Hackathon
- Hackpad: https://lite5.framapad.org/p/hack@moz
- PDF presentation: File:Porting OFF on Firefox OS.pdf
- https://github.com/gasolin/qrcode_scanner/
- https://github.com/SunboX/QR-Reader
How to hack it / install it
Get the source code
Clone the Open Food Facts Firefox OS Cordova repository
git clone https://github.com/openfoodfacts/openfoodfacts-ffos.git
Github repo with the app debugged during the Hackathon
Install the App Manager
Install it on your device
Windows Phone
Ubuntu OS
Separate application and codebase. See #ubuntu on Slack