Cordova


What is Cordova?



Cordova is an open-source mobile development framework.



What can I do?





Cordova allows you to use standard web technologies such as HTML5, CSS3, and JavaScript for cross-platform development, avoiding each mobile platforms' native development language.

Cordova or PhoneGap?




PhoneGap is a distribution of Apache Cordova. You can think of Apache Cordova as the engine that powers PhoneGap, similar to how WebKit is the engine that powers Chrome or Safari.


PhoneGap, Cordova, and what the hell is in a name?

PhoneGap官网

Windows / Cordova / Android





为了便于快速开始开发,以 Windows 环境下,Cordova 的 Android 开发为例



其他的平台类似

Android ADT


首先需要下载  Android  开发工具系列套装


Apache Ant


下载 Apache Ant 构建工具


导入 Path

告诉电脑我把 ADT 和 Ant 安装到了哪里

ADT

D:\adt-bundle-windows-x86-20130522\sdk\tools

D:\adt-bundle-windows-x86-20130522\sdk\platform-tools

Ant
D:\apache-ant-1.9.3\bin

Node.js





Install



Npm install Cordova





( sudo ) npm install -g cordova

Create App




cordova create hello com.example.hello HelloWorld


The first argument specifies a hello directory to be generated for your project.
The other two arguments are optional: the com.example.hello argument provides your project with a reverse domain-style identifier, and the HelloWorld provides the application's display text.

Create successful






Add platform


cd ./hello


cordova platform add android

(cordova platform add ios)

...


Then Build




cordova build android

==

cordova prepare android
+
cordova compile android

First Build Tips


初次 build,会下载 lib,而且很长时间,可以手动下载好Cordova 源码包

 
把下载的cordova-3.4.0-src文件夹里面的cordova-3.4.0\cordova-android拷贝至C:\Users\XXX\.cordova\lib\android\cordova\3.4.0 \目录下即可【其他平台类似】

First Build Tips


如果遇到:



将安装的 java/jdk/lib 中的 tools.jar 复制一份到 java/jre/lib 中

Build Successful





After Build + CLI


打开仿真器或者 USB 连接手机【打开调试模式】

Then

cordova emulate android

Or

cordova run --emulator android

cordova run --device android

After Install



Add Your Plugin





cordova plugin add org.apache.cordova.contacts

Enjoy It





Code Your Code...

After Build + Eclipse


build完成后,已经生成了整个项目结构和主要文件


Open Eclipse,Import Them


plateform/android

Tips For Eclipse



初次导入如果缺少源文件,就从下载的Cordova源码包中Copy 里面的 com 和 org 源码包


Enjoy It




Run as

Android Application


Code Your Code...

CLI : Cordova & PhoneGap Tips



phonegap build xxx == cordova platform add xxx + cordova build xxx

phonegap run xxx == phonegap build xxx + phonegap install xxx

cordova run xxx == cordova prepare xxx  + cordova compile xxx

Platform Support


More






The End





Q&A
Made with Slides.com