参考: Phonegap官网 Getting Started with Android
http://docs.phonegap.com/en/2.7.0/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android
PS: phonegap和cordova其实现在都一样了。个人感觉以后还是cordova发展的会更好, mark下。
http://cordova.apache.org/index.html#top
http://baike.baidu.com/view/8326345.htm
PhoneGap 和 Cordova的关系阐述
是PhoneGap贡献给Apache后的开源项目,是从PhoneGap中抽出的核心代码,是驱动PhoneGap的核心引擎。你可以把他想象成类似于Webkit和Google Chrome的关系。
最近在网上搜索如何为Android配置Phonegap开发环境,关键字: Android Phonegap; ADT Bundle Phonegap;
搜出来很多文章,但是看了一下,越看越糊涂,很多都说要把phonegap目录下的各种js 和 jar包等等copy到各个相应的android 项目的目录下,然后还要改一些xml配置等等,太麻烦了。。。
后来干脆去看官方网站是怎么说的。
其实仔细看看官方网站的介绍,里面写的非常简洁和容易。 这里把关键步骤大概翻译一下吧
1.安装Android SDK, 现在最近的SDK包含了如下组件,所以不需要向以前一样从eclipse,然后SDK,ADT一点点配置了,傻瓜化了,把这个压缩包解压到硬盘里就能用了。
如解压到C:\根目录, c:\adt-bundle-windows-x86_64, 也可以改个名字如c:\Android
Download and install Android SDK
2. 下载Phonegap
Download the latest copy of PhoneGap and extract its contents. We will be working with the Android directory.
下载后解压到C盘根目录 如 c;\phonegap-2.7.0
3. Setup your PATH environment variable on Windows
相信大部分人都是用的windows吧,所以mac的部分就不说了。 大家按下面的步骤操作就OK了,很简单。
;C:\Development\android-sdk-windows\platform-tools;C:\Development\android-sdk-windows\tools
%JAVA_HOME%\bin
to your PATH as well. To check to see if this is required, run a command prompt and typejava
. If the program can not be found add %JAVA_HOME%\bin
to the PATH. You may need to specify the full path instead of using the%JAVA_HOME%
environment variable.%ANT_HOME%\bin
to your PATH as well. To check to see if this is required, run a command prompt and typeant
. If the program can not be found add %ANT_HOME%\bin
to the PATH. You may need to specify the full path instead of using the%ANT_HOME%
environment variable.4.1 创建phonegap项目工程目录
bin
directory within the android
subfolder of the Cordova distribution.
Type in ./create
then press"Enter"
这个如果在windows下这么打肯定不行,直接输入create
然后回车,如下:
create C:\Workspace\hellophonegap com.demo.hellophonegap hellophonegap 这里说明下如果workspace中间有空格则会失败。
然后在DOS里会出现如下信息:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Creating new android project...
Copying template files...
Copying js, jar & config.xml files...
Copying cordova command tools...
Updating AndroidManifest.xml and Main Activity...
is the path to your new Cordova Android project
is the package name, e.g. com.YourCompany.YourAppName
is the project name, e.g. YourApp (Must not contain spaces and dashes)
If you're getting an 'An unexpected error occurred" error, try the command again prefixed withsudo
4.2 导入Android SDK开发环境中
If your project has a red X indicating there is a problem follow these additional steps:
5. Deploy to Emulator
Note: For a faster experience, use an Intel-based emulator image:
Intel x86 Atom
System Images as well as the Intel Hardware Accelerated Execution Manager
(under Extras).extras/intel/Hardware_Accelerated_Execution_Manager
within your Android SDK6. Deploy to Device