最新版 android studio 配置 phonegap (windows环境)

来源:互联网 发布:db2和sql server 编辑:程序博客网 时间:2024/06/07 17:54
参考官方  


http://docs.phonegap.com/develop/1-embed-webview/android/


1、下载cordova-android

下载地址  https://github.com/apache/cordova-android

下载zip文件之后,解压,启动cmd框 进入到该解压之后的 bin 目录之后,执行创建phonegap项目

C:\cordova-android-master\bin>  create c:\phonegap\myApp

这样,在 c:\phonegap 下 就创建了名为myApp的phonegap项目


2、安装plugman

根据其官方介绍 https://github.com/apache/cordova-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://blog.csdn.net/renfufei/article/details/41647875 和 http://blog.csdn.net/exlsunshine/article/details/18939329  需要说明的是,上述第二篇参考文章中,git-core的位置变为 Git\mingw64\libexec,其余的不再赘述。

搞定git之后,在cmd框中,执行 > npm install -g plugman  即安装完毕plugman


3、安装android支持

cmd框中,进入到刚才创建的myApp项目的目录中,分别执行如下三条命令

> plugman install--platformandroid --project. --plugincordova-plugin-whitelist                                                                                                                                                       > plugman install--platformandroid --project. --plugincordova-plugin-device        
> plugman install--platformandroid --project. --pluginnl.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中,<head>下添加一条代码

<meta charset="utf-8" />

以避免中文乱码。至此运行模拟器,就可以看到效果了。




0 0
原创粉丝点击