Discussion on advantages and disadvantages of Cordova and environment deployment
Suhuajie
Brief introduction
Cordova is a fast-developing platform for creating cross-platform mobile applications using HTML, CSS, and JavaScript. It enables developers to take advantage of the core features of smartphones such as the iphone, Android, Palm, Symbian, WP7, Bada, and BlackBerry-including geolocation, accelerators, contacts, sounds and vibrations-in addition to Cordova's rich plug-ins, can be called.
Advantages and Disadvantages
Today's popular mobile Web applications can be divided into three types: native applications, Web applications, and hybrid applications.
- Native applications: Installed in a variety of application markets, using platform-specific language development.
- Web Apps: Web-based technology for browser access.
- Hybrid applications: Installed through a variety of application markets, but with web-based technology development. Although it appears to be a native application, it is actually a Web application.
Benefits of native applications:
- Provide the best user experience, the highest quality user interface and the most gorgeous interaction;
- Provide different experiences for different platforms;
- can save bandwidth cost;
- access to local resources;
- The profit model is clear.
Disadvantages of native applications:
- Porting to different platforms is more troublesome;
- High cost of maintaining multiple versions;
- Need to be confirmed by store or market;
- Profitability needs to be partitioned with third parties.
The advantages of Web applications are as follows:
- Low development cost;
- The cost of adapting to a variety of mobile devices is low;
- Cross-platform and terminal;
- iterative update is easy;
- No installation costs.
The disadvantages of Web applications are as follows:
- The browsing experience is not yet beyond native applications in the short term;
- Offline mode is not supported (HTML5 will solve this problem);
- Message push is not timely;
- The ability to invoke the local file system is weak.
Hybrid applications can be said to compensate for the shortcomings of the above two application development models, which are a mixture of both products, and as far as possible inherit the advantages of both sides:
First, it can transform almost 0 of thousands of Web developers into mobile app developers.
Second, the same code can only be compiled for different platforms to achieve multi-platform distribution, greatly improving the efficiency of multi-platform development. Rather than Web applications, developers can invoke most of the commonly used system APIs through a packaged interface.
As described in this article, Cordova,cordova is the leader in the hybrid framework, which is based on standard Web technology--html, JavaScript, and CSS, and is used by the developer to invoke the API of the JavaScript wrapper platform. Powerful compiler tools to build applications for different platforms, with rich third-party resources and industry chains.
PhoneGap provides an excellent cross-platform solution by building a communication bridge between Web applications and devices, encapsulating platform differences for mobile devices, and using JavaScript interfaces to access device local APIs.
I believe we have a general understanding of the use of mobile application development frameworks. The next step is to describe the Cordova environment deployment.
To deploy Cordova using the command line:
1. Installing Nodejs
Download: http://nodejs.org/download/. Reboot is required after installation.
2. Installing Cordova
Open cmd command line, execute: NPM install-g Cordova
Installation for about 10 minutes.
3. Install Ant
Download the ant package and extract it to a folder such as: D:\program files\apache-ant-1.9.4
Configure the path to the environment variable, which is configured when the Android SDK does not configure environment variables. In case of a subsequent error.
4. Create a Cordova Project
Cordova Create Hello Com.shj.helloworld HelloApp |
Where the first Hello is the name of the folder, Om.shj.helloworld is the app ID, the second helloapp is the name of the project, and the name of the app.
Prompt to download the library, please wait.
Download complete.
5. Enter the project folder
6. Add Platform Support
There are multiple platforms to choose from. The command is as follows:
$ Cordova Platform Add ios$ Cordova Platform add amazon-fireos$ Cordova Platform add android$ Cordova Platform Add BLACKBE rry10$ Cordova Platform Add firefoxos$ Cordova Platform add wp7$ Cordova Platform add wp8$ Cordova Platform Add windows8 |
Choose Cordova Platform Add Android here
Enter the command under the project folder:
The project is created.
7. Add plugin Support
Mainly for the system hardware access to plug-ins, common such as cameras, media access, device access, acceleration equipment, positioning equipment and so on. Can be dynamically on demand to add, such as the following ways to add, more plug-ins please go to Cordova official website to view.
Basic device information (device API):
$ Cordova Plugin Add Org.apache.cordova.device |
Network connection and Battery events:
$ Cordova Plugin Add org.apache.cordova.network-information$ Cordova plugin add org.apache.cordova.battery-status |
Camera, media replay, and capture:
$ Cordova Plugin Add org.apache.cordova.camera$ Cordova plugin add org.apache.cordova.media-capture$ Cordova plugin Add or G.apache.cordova.media |
To access a file on a device or network (file API):
$ Cordova Plugin Add org.apache.cordova.file$ Cordova plugin add Org.apache.cordova.file-transfer |
8. Build your App
Cordova Build
If this command appears, update the ant version
The prompt appears, and build succeeds. The content to be hello/www will be built into each platform that is added. such as the Android platform, will be built into this directory: Hello\platforms\android\assets\www.
9. Test your application
A) Install the test application on the simulator
such as Android, you should start and open the Android emulator first.
B) Use the real Machine test (recommended)
You can use the following command:
C) running in the browser
D) Debug with Ripple Emulator
NPM install-g Ripple-emulatorripple Emulate |
Packaging for published apps
Pack Android apps: with Eclipse.
Open the install eclipse with the ADT plugin configured, use the wizard to import an Android project, select the current project folder, the import of two items will be displayed, import.
The project was successfully brought in.
Next, you can put the Web page directly into the project.
First look at the effect of the PC directly opening the page.
This is the startup interface for the unmodified configuration. This is the Web page that just opened on the PC. The Web page exists under the Android Project Asset directory. The reference path is as shown in file:///android_asset/www/index.html
Through the 360 mobile phone assistant to view the phone interface, you can see that the interface has been successfully booted in.
The deployment of the environment in this Cordova has been accomplished. Web developers can easily develop mobile apps. More detailed plug-ins please check the official website, do not elaborate on this.
Original address: http://express.ruanko.com/ruanko-express_74/technologyexchange6.html
Brief discussion on advantages and disadvantages of Cordova and Environment Deployment (reprint)