Thursday, July 9, 2015

Cordova hurdles


Cordova setup steps (windows 7 + Android):

Pre-requisites
1. Download npm here  and setup. Its a package management tool to install cordova.
2. JDK 7
3. Android emulator or device. Ant might be required for older versions. newer version use gradle build system.

Setup cordova CLI (command line client)
1. From DOS prompt run >npm install -g cordova@x.x.x
Note: cordova specific version can be installed using x.x.x eg: 5.0.0 or remove it for default latest version.

Create Cordova project
  1. cordova create directoryName com.package AppName
  2. cd directoryName
  3. cordova platform add android@x.x.x
  4. cordova plugin add
  5. cordova build android/ios --release
  6. cordova run android/ios --device

Setup on eclipse
1. Follow blog
This is still work in progress... Will share once it is done.

Debug
Add Debug Console plugin to your project by running this command:
$ cordova plugin add org.apache.cordova.console
To see debug output adb logcat CordovaLog, but generates too much logs.

Or use remote debugging http://jsconsole.com/remote-debugging.html (way better logs)

Gotchas
  1. cordova build command first time downloads gradle. On cordova 5.1 had issue downloading it, the fix was as below :
    1. Stackoverflow link
    2. update ..\platforms\android\cordova\lib\build.js (search for .zip and replace to ../[].zip)
  2. Cordova plugin are downloaded from npm package (like maven). 
  3. aidl files failed to compile :  fix
aidl -I/Volumes/work/projects/java/android/cordova/hello/platforms/android/src -p/Volumes/work/projects/java/frameworks/android-sdk-mac_x86/platforms/android-22/framework.aidl IInAppBillingService.aidl

4. Android API 16+ requires JDK 7+ only. And mac Snow Leopard 32 bit doesnt support JDK 7 anymore (ridiculous). Mac is such a waste of time when it comes to backward compatibility.



5. I am yet to figure out how to run cordova(newer projects) from eclipse. Running from CLI is fine, but how can we debug like logcat in eclipse Juno?


6. The cordova.js ,cordova.jar and cordova_plugin.js are generated under \platforms\android\build\intermediates\assets\debug\www\cordova.js
Note the way plugins are included in later version of cordova is through JS.
7. To rename app : http://www.stefangordon.com/renaming-your-cordova-application/


Ionic

https://ionicframework.com/docs/intro/installation/ 1. npm install -g ionic cordova 2. ionic start letsgo-mobile blank 3. cd letsgo-mobile 4. ionic serve