Cordova configuration and development

Source: Internet
Author: User
1. Environment configuration 1. 1. Install ant

Download ant from the Apache official website, install and configure ant. bat, and add the directory where ant. bat is located to the PATH environment variable, such as c: \ apache-Ant \ bin \. Run the following statement in cmd without any error:

> Ant-H

1. 2. Install git

Download and install git from the GIT official website.

1.3 install nodejs

Download and install it from the nodejs website. After the installation is successful, enter the command: node or NPM on the command line. No error is reported.

1. 4. Install CORDOVA

> NPM install-G CORDOVA

2. Create a project

A. Create a folder as the working directory. Switch to the directory by CMD.

> Cd D: \ workspace \ CORDOVA

B. Create a Cordova Project

> Cordova create hellocordova com. hzjava. mycordova hellocordova

C. Add platform support

First, go to the root directory of the project you just created.

> Cd hellocordova

Then

> Cordova platforms add IOS
> Cordova platforms add android
> Cordova platforms ls

D. Add plug-ins (add plug-ins based on specific functions, such as code scanning plug-ins and file operation plug-ins. You can search the required plug-ins in the Cordova plug-in Library)

> Cordova plugin add com. phonegap. plugins. barcode.pdf
> Cordova plugin add org. Apache. Cordova. File-Transfer
> Cordova plugin ls

Note: not all plug-ins are supported by the entire platform. Some may only support Android, while some may support Android and IOS at the same time. Therefore, you must carefully select plug-ins when developing multi-platform apps.

3. Project Integration 3.1.android

A. Copy the static html file to the hellocordova \ WWW directory.

B. Compile the android project:

> Cordova build android

C. Run eclipse and import the android project under the hellocordova \ platforms \ Android path

D. Reference The Cordova JS library in HTML:

<SCRIPT type = "text/JavaScript" src = "Cordova. js"> </SCRIPT>

<SCRIPT type = "text/JavaScript" src = "cordova_pluginjs"> </SCRIPT>

3.2.ios

A. Copy the static html file to the hellocordova \ WWW directory.

B. Compile the IOS project:

> Cordova build IOS

C. Run xcode and import the xcode project under the hellocordova \ platforms \ IOS path.

D. Reference The Cordova JS library in HTML:

<SCRIPT type = "text/JavaScript" src = "Cordova. js"> </SCRIPT>

<SCRIPT type = "text/JavaScript" src = "cordova_plugins.js"> </SCRIPT>

  • Cordova will copy the files under the [root directory/WWW] To the WWW folder of the specific platform. If your code is written in Android of platforms, it will be overwritten during compilation.
  • Because the relevant configuration has been automatically added when addplugin is, as long there is cordova_plugin.js, you do not need manual reference of the Js of Cordova.
4. Package 4.1.android

Two projects are displayed when the project under platforms \ Android is imported: hellocordova and hellocordova-cordovalib. When packaging, copy hellocordova-cordovalib/bin/hellocordova-cordovalib.jar to the hellocordova/libs folder, right-click the main project, select export,

Select export Android Application

You can create a new keystore by yourself or use the existing

Click Finish to export the APK.

4.2.ios

To package an iOS installation package (IPA) that can be installed on any device, you need an enterprise developer account ($299/year). After confirming that the installation meets the requirements, perform the following steps:

A. log on to the Apple Developer Center.

B. Identifiers> app IDs, click "+", create an app ID, and enter the relevant information for the next step.

C. provisioning profiles> distribution, click "+" to create a profile

Select in house

Select an app ID and select the one you just created

Select a certificate

Enter profile name

D. Download the created profile file.

E. Download the Certificate file selected in Step C.

F. Double-click the certificate and profile files on Mac to import them.

G. Open xcode, select the project, build Settings> code signing, code signing identity select the registered company name

H. provisioning profile select the profile you just imported

I. xcode> WINDOW> organizer> archives, click distribute

J. Select save for enterprise or ad hoc deployment. Next Step

K. Select a profile to sign and then export

Cordova configuration and development

Related Article

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.