参考官方
1、下载cordova-android
下载zip文件之后,解压,启动cmd框 进入到该解压之后的 bin 目录之后,执行创建phonegap项目
C:\cordova-android-master\bin> create c:\phonegap\myApp
这样,在 c:\phonegap 下 就创建了名为myApp的phonegap项目
2、安装plugman
You must have git on your PATH to be able to install plugins directly from remote git URLs. 故安装plugman 需要首先搞定git,并且git还得放入系统环境变量中。所以我们首先搞定git先。git的安装与配置参考 http://www.voidcn.com/article/p-eoxafahv-bme.html 和 http://www.voidcn.com/article/p-gmhddugs-cp.html 需要说明的是,上述第二篇参考文章中,git-core的位置变为 Git\mingw64\libexec,其余的不再赘述。
搞定git之后,在cmd框中,执行 > npm install -g plugman 即安装完毕plugman
3、安装android支持
cmd框中,进入到刚才创建的myApp项目的目录中,分别执行如下三条命令
> plugman install --platform android --project . --plugin cordova-plugin-whitelist > plugman install --platform android --project . --plugin cordova-plugin-device
> plugman install --platform android --project . --plugin nl.x-services.plugins.toast
即安装android支持完毕
4、导入到android studio中
打开android studio,若界面是上次编辑项目,则执行 File > Close Project,则出现 Welcome to Android Studio 界面,在此界面选择下方的 Import project(Eclipse ADT,Gradle,etc),导入刚才的 myApp 项目,即导入成功。
导入成功之后,点击android studio左侧的竖向的structure,打开项目结构,找到 assets>www>index.html中,
下添加一条代码以避免中文乱码。至此运行模拟器,就可以看到效果了。