3.0是通過nodejs安裝的,不像以前的版本有安裝包
到此安裝成
設(shè)置系統(tǒng)變量
系統(tǒng)變量 Path后面添加:
新增 JAVA_HOME,設(shè)置值為java sdk 根目錄:
C:\Program Files (x86)\Java\jdk1.6.0_10\
下面就構(gòu)建應(yīng)用吧
phonegap create hello com.helloworld.hello helloworld
第一個(gè)參數(shù)hello表示項(xiàng)目文件夾名,在此文件夾下會(huì)生成www子目錄作為主頁面存入目錄,包括有css,js和img資源。 其中config.xml包括了重要的資源描述和項(xiàng)目配置信息.
第2個(gè)參數(shù)是可選的,com.vmeitime.hello表示項(xiàng)目包名; 第3個(gè)參數(shù):HelloWord表示顯示的文本;
接下來,添加相應(yīng)平臺(tái)
cd hello 進(jìn)入項(xiàng)目路徑
為項(xiàng)目添加插件,然后再生成不同平臺(tái)下的項(xiàng)目.
添加插件(需要先安裝git工具 https://help.github.com/articles/set-up-git):
PhoneGap 3.0 最需要關(guān)注的是完全的插件體系結(jié)構(gòu),所有的功能特性包括攝像頭等都是使用插件方式提供。也就是說新建項(xiàng)目后很多功能是無法使用的,你必須將其對(duì)應(yīng)的插件添加到項(xiàng)目中。
例如在 cordova 中添加插件的方法是:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
而通過 phonegap 命令行工具的方法是:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
這意味著在開始 PhoneGap 項(xiàng)目時(shí)你要先考慮項(xiàng)目需要什么功能,然后通過命令行來添加這些功能。
1). 添加的插件都將放在C:\hello\plugins目錄下.
2). 同時(shí)會(huì)在所有平臺(tái)下的config.xml文件中增加feature插件配置,如:C:\hello\platforms\<平臺(tái)>\res\xml\config.xml)
3). 增加相應(yīng)的插件java文件:C:\hello\platforms\android\src
4). 增加相應(yīng)的插件js文件:C:\hello\platforms\android\assets\www\plugins
下面是完整的插件列表,我直接拷貝過來,可能會(huì)有變化:
Basic device information (Device API):
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
Network Connection and Battery Events:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status.git
Accelerometer, Compass, and Geolocation:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
Camera, Media playback and Capture:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
Access files on device or network (File API):
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
Notification via dialog box or vibration:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git
Contacts:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git
Globalization:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization.git
Splashscreen:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git
Open new browser windows (InAppBrowser):
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
Debug console:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
運(yùn)行build命令,輸入不同平臺(tái)標(biāo)識(shí),生成不同平臺(tái)下的相應(yīng)文件。如下以android設(shè)備為例:
c:\hello> phonegap build android
要查看詳細(xì)(verbose)執(zhí)行過程,可增加命令參數(shù)-V :
c:\hello> phonegap -V build android
之后可以看到C:\hello\platforms\android里出現(xiàn)Android項(xiàng)目。
下面你就導(dǎo)入進(jìn)eclipse 編輯吧
是不是比以前創(chuàng)建應(yīng)用方便多了
如果遇到j(luò)ava問題,可能你要換到j(luò)dk1.6
聯(lián)系客服