- 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
- C語言程序設計案例教程(第2版)
- Vue.js 2 and Bootstrap 4 Web Development
- 網店設計看這本就夠了
- Serverless架構
- Android程序設計基礎
- C和C++游戲趣味編程
- Android嵌入式系統程序開發:基于Cortex-A8(第2版)
- Emotional Intelligence for IT Professionals
- OpenCV 3計算機視覺:Python語言實現(原書第2版)
- 多媒體技術及應用
- 會當凌絕頂:Java開發修行實錄
- Developing Java Applications with Spring and Spring Boot
- Tkinter GUI Programming by Example
- Linux Networking Cookbook
- 開源網絡地圖可視化:基于Leaflet的在線地圖開發