Mobile App/Cordova Development Notes: Difference between revisions

From Open Food Facts wiki
Line 26: Line 26:
<pre>npm install -g cordova</pre>
<pre>npm install -g cordova</pre>


cordova -v : 3.6.3-0.2.13
<pre>cordova -v : 3.6.3-0.2.13</pre>


Install your platforms
Install your platforms
Line 33: Line 33:
cordova platform add android
cordova platform add android
</pre>
</pre>
=== errors ===
=== Errors ===


* "error android_home is not set and android command not in your path" when doing "cordova platform add android"
==== "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)
**Install Eclipse ADT  (Note : for win8 32bit/64bit install 32bit ADT)
Line 44: Line 44:
*** 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
*** 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"
===="error failed to run javac -version make sure" ====


Java JDK
Java JDK

Revision as of 20:45, 22 October 2015

This page contains notes regarding the development of the Open Food Facts mobile apps.

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

Installing Node.js

Install Node.js

Install Git client

Install Cordova

in git-bash client:

npm install -g cordova
cordova -v : 3.6.3-0.2.13

Install your platforms

cordova platform add firefoxos
cordova platform add android

Errors

"error android_home is not set and android command not in your path" when doing "cordova platform add android"

"error failed to run javac -version make sure"

Java JDK

ANT

"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.

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


Install Moodstocks

Instructions pas à jour pour Cordova 3.6 on dirait, par contre il y a un autre 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")
  }

Cordova plugins

Bugs

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" ?

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

Barcode scanning plugin

You may also have to install Apache Cordova plugin for barcode scanning.

cordova plugin add com.phonegap.plugins.barcodescanner

Firefox OS

Ubuntu OS

Separate application and codebase. See #ubuntu on Slack

Publishing on App Stores

Import on Apple App Store

  • You need a Mac to do this.

Import on Google Play

  • "You have imported an APK file which is not zip-aligned. Veuillez exécuter un utilitaire d'alignement zipalign sur votre fichier APK, puis le réimporter."

May be of interest for future apps