Start your mobile development journey with PhoneGap

Source: Internet
Author: User
Tags install node

The mobile market is surging, just as if it were isolated from the sad. NET programmer. The Windows Phone that we've been waiting for is never going to be a window, and as time goes by, Windows Phone is increasingly like a fools, even Microsoft has the idea to give up. Looking at the news, Microsoft intends to let Windows Phone support Android apps, Nokia out of the Android phone ...
. NET developers in the mobile market? The phonegap described below may be one of our choices.

One, what is PhoneGap?

Mobile apps are hot, but there are too many development platforms. The big platform is Android and iOS, and there are other platforms like Windows Phone, BlackBerry ... Different development platforms need different development language, the development of Android, need to learn Java; Developing iOS apps requires learning object-c.
Cross-platform is not the direction of the major companies have been working hard? However, in the end for their own calculations, or open the Pandora's box. When the hard-pressed programmer implements the app on Android and implements it again on iOS, this is in violation of our principle of DIY (do not REPEAT yourself).
So on the mobile side, there is no cross-platform development way? Actually always have, really can cross the platform is HTML + CSS + JS. This is the Web App. Web apps can be used on any platform, as long as they have a browser. But web apps have limitations and cannot invoke and manipulate local devices such as cameras, GPS, push messages, etc.
And PhoneGap is to solve this problem, it can let us use HTML +css +JS to develop the application, but also let us like the local app, easy to invoke device and operating system interaction.

Second, how did PhoneGap do it?

Web apps developed using HTML+CSS+JS will be phonegap packaged into WebView and embedded in the release app. The final packaged app is actually a shell, and the Web app we've developed is packaged in the shell. For different platforms, PHONEGAP will compile the package using a different platform.
The call to the native API is done through the JS call. The code for these calls is also translated into code for different platforms by PHONEGAP, enabling interaction with different sets. That's what the phone Gap Bridge does.

Third, the advantages and disadvantages of phonegap

Seeing the brief introduction above, theadvantages of PhoneGap should be seen:

1. Cross-platform

Using the Java AD language, PhoneGap implements the write once on the mobile platform, run anywhere.
PhoneGap currently supports mobile platforms: Android, IOS, Windows Phone, Windows 8, Firefox OS, Amazon Fire OS, BlackBerry, Ubuntu, Tizen. are satisfied with it! )

2. High cost performance, low development difficulty

As long as you're html+css+js, you can develop apps that run on up to 8 mobile platforms, and do you have a more cost-effective technology than that?
Developers who believe in the front-end of HTML should be much more than any other language developer. But for server-side development, there's no limit to mastering a different language, PHP, Java,. NET, Ruby or Python.
However, the more compatible the technology, the lower the cost, the worse the performance, the worse the compatibility of the technology, the higher the cost, the better performance. PhoneGap can be compatible with so many platforms, nature is not very efficient. Let's talk about PhoneGap's shortcomings.

PhoneGap deficiency:

1. Operating efficiency

PhoneGap's operation relies on the webkit of the built-in browser on the mobile device, so running speed is naturally slower than the native app.

2. Unable to support all system APIs

Because of the need to support multiple platforms, if some of the platform's unique API, on the PHONEGAP may not be able to receive timely support.
In today's thousand yuan, can buy four nuclear mobile phone era, the general app is not very operational efficiency problems. But if you want to develop a complex 3D game, then the native app is definitely the best choice.
In addition, personal opinion, thehistory on the PC will be repeated on mobile, will eventually go to the web.

Iv. installation of the PHONEGAP development environment step by step

Installed according to the official documentation, a lot of pits are full. Below is a detailed description of how to install the PhoneGap development environment under Windows. The following list is only to write the article of the current effective, may expire later, if invalid, you can go to the official website to download.

1. Install node. js

Http://www.nodejs.org/download/on the node. JS official website. Download the Nodejs installation package.
After the installation is complete, add the path of the Nodejs to the system variable path.

2. Install the Cordova CLI (Cordova command-line interface)

Install the Cordova CLI in the command line run

If the NPM command is not found, there is a problem with the path configuration. If you are sad about the installation error, it is because GFW egg https://registry.npmjs.org to the wall, resulting in unable to install the module through NPM. Need to

NPM configures the agent.

NPM Config set proxy=http://127.0.0.1:9999
NPM Config set https-proxy=http://127.0.0.1:9999
The proxy address above needs to be replaced by your own.

3. Configure Android Development Platform

3.1 Download and install the latest JDK

Download and install the latest JDK on the official website
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

3.2 Download Android SDK

Download and install the latest Android SDK on the official website
Http://developer.android.com/sdk/index.html

3.3 Download Apache Ant

Download and install the latest Android SDK on the official website
http://ant.apache.org/bindownload.cgi

3.4 Configuring environment variables

To add a new environment variable, adjust the following path according to the installation path:

Android_home Value:c:\program FILES\ADT-BUNDLE-WINDOWS-X86_64-20140321\SDK
Ant_home Value:c:\program Files\apacheant
Java_home Value:c:\program files\java\jdk1.8.0_05

Add path
%java_home%\bin;%ant_home%\bin;%android_home%\platform-tools;%android_home%\tools;

Five, first Android App:hello world

First, under the folder path where you want to create the project, run the following command to create the HelloWorld project

Next, add Android platform support for the project.

Then, in the installation directory of the Android SDK, there is an SDK Manager.exe program that starts the program on the command line.
In Tools->manage Avds, create a new Android emulator.

Finally, we can start compiling and running our first PHONEGAP program on the Android platform.

The result of starting the run:

Six, in-depth development

The above app shows the screen, in fact, we created the HelloWorld project in the WWW directory under the index.html

Development of a cross-platform application, just need us in the WWW directory, the Web app can be done.
The choice here is more, you can use Bootstrap, jquerymobile ...
In addition, you need to learn how to invoke the System API in PhoneGap.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.