- PhoneGap:Beginner's Guide(Third Edition)
- Purusothaman Ramanujam Giorgio Natili
- 461字
- 2021-07-16 13:22:26
Time for action – setting up Android using PhoneGap 3.x
Get ready to set up the Android development environment and create a PhoneGap app using Android as the target platform. In the previous section, we saw how to create a new project. Now it's time to add the desired platform to the project. As usual, use Terminal on OS X or DOS Prompt on Windows to run these commands.
- Launch a command-line tool (DOS or Terminal) and change the directory to the directory where we just downloaded the Cordova/PhoneGap distribution, as shown here:
$ cd hello
- In order to create a PhoneGap project for Android, all you have to do is run the command to add a platform to the project:
$ phonegap platform add android
The command tells Cordova to add support for the Android platform. After the successful execution of the command, you can see a new directory named android
created inside the platform directory. This contains all the platform-dependent files.
Now it's time to run the project in the emulator. The following command will take some time to complete:
$ phonegap emulate android
The tool will check whether some virtual devices are already defined and prompt the user to define one if not. If there is more than one device already defined, the tool will ask which one to use.
What just happened?
You created a PhoneGap project and emulated the app in one of the testing devices configured within your Android SDK.
Working with other platforms
To work with different platforms such as iOS, Windows Phone, and others, you have to follow the same process that we did for Android. The list of platforms that you can add to your project depends on the platform name. Before you add the platforms, you should ensure that you have the required SDKs installed on your machine.
On a Windows machine, you can run any of the following commands provided you have the required SDKs installed for each platform. You will not see the iOS platform here as we need a Mac machine to work on iOS:
C:\hello> phonegap platform add wp7 C:\hello> phonegap platform add wp8 C:\hello> phonegap platform add windows8 C:\hello> phonegap platform add amazon-fireos C:\hello> phonegap platform add android C:\hello> phonegap platform add blackberry10 C:\hello> phonegap platform add firefoxos
In the preceding commands, wp7
and wp8
denote Windows Phone 7 and 8, respectively.
On a Mac machine, you can develop on the following platforms after installing the corresponding platform SDKs. You will not see the Windows Phone platform here as we need the Windows operating system to install the Windows Phone SDK:
$ phonegap platform add ios $ phonegap platform add amazon-fireos $ phonegap platform add android $ phonegap platform add blackberry10 $ phonegap platform add firefoxos
- Python入門很簡單
- Learning Docker
- Building a Game with Unity and Blender
- FFmpeg入門詳解:音視頻流媒體播放器原理及應用
- OpenNI Cookbook
- 利用Python進行數據分析(原書第3版)
- FPGA Verilog開發實戰指南:基于Intel Cyclone IV(進階篇)
- Raspberry Pi Robotic Blueprints
- R語言數據可視化:科技圖表繪制
- C++ System Programming Cookbook
- Java RESTful Web Service實戰
- Java程序設計入門(第2版)
- Flask開發Web搜索引擎入門與實戰
- Learning WordPress REST API
- Backbone.js Patterns and Best Practices