phonegap cordova 环境搭建及安装

原文地址为: phonegap cordova 环境搭建及安装

因为学校有项目需要快速开发出来所以选择了phonegap+html5的结构来搞,第一步就是搭建phonegap环境。

phone gap说白了就是一个封装器,可以创建出​自动创建出安卓工程或ios的,你只需要把写好的html文件拖入,然后就可以打包成apk了。言归正传,来说环境搭建,当然前提是电脑里有jdk了。

第一步,百度搜索nodes,官网下载下来,下recommended for most users 那个版本​,然后点next,next安装完就好。

phonegap 及cordova环境搭建 填写图片摘要(选填)

第二步,打开cmd,mac的话就打开终端,输入命令,node -v;

确认一下是否装好,若能正常显示版本号,则输入npm install -g phonegap 

若是安装cordova 则是​npm install -g cordova 

第三步, phonegap ​ 创建project   依旧是在cmd   输入phonegap ​create test

然后跳转到test文件夹里,继续在cmd输入 phonegap build android 

系统会自动将test工程封装成一个安卓工程,可以导入ecplise 进行打包使用​了,导入的时候含build的可以不导入。

phonegap 及cordova环境搭建 填写图片摘要(选填)


注意:

一、build 过程中可能会遇到​报错,说找不到ANDROID_HOME路径,那是因为你没有配置sdk环境变量,windows下配置http://jingyan.baidu.com/article/f71d603757965b1ab641d12a.html

mac下配置的方法为:

1、$  export ANDROID_HOME=/Users/mac/adt-bundle-mac-x86_64-20131030/sdk

$  export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

2、Setting ANDROID_HOME environment variable to .bash_profile

Open the Terminal program present in your (this is in your Applications/Utilities folder by default). Follow the below steps.

Step-1

Start up Terminal and go to your home folder.

cd ~/

Step-2

Open and edit .bash_profile file

$ open -e .bash_profile

If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.

touch .bash_profile

Step-3

Save the below line)

export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools

export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools

 Step-4

Refresh the file using below command

$ source .bash_profile

Step-5

Check if the JAVA_HOME is set properly

$ echo $PATH

You will see the result similar to below. Find for your path in there. If available, then you are good

/Users/Neel/.rvm/gems/ruby-2.1.2/bin:/Users/Neel/.rvm/gems/ruby-2.1.2@global/bin:/Users/Neel/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:/Users/Neel/.rvm/bin

​二、建议sdk用最新版的,android 23最好,其余的尽量删除,否则容易出现错误



转载请注明本文地址: phonegap cordova 环境搭建及安装

猜你喜欢

转载自blog.csdn.net/hong2511/article/details/80973826