Phonegap (Cordova) Create a project and package build APK package with Eclipse development tools

Source: Internet
Author: User

1. Create and edit the project using PhoneGap (Cordova)

(1) Create a folder to hold the Android program created later, here we create a folder on the E-Androidproject, the appropriate CD command to enter the directory, the next applicable phonegap command to create the corresponding Android project.

PhoneGap Creation Instructions:

PhoneGap Create Hello Com.example.hello HelloWorld

Hello: your project folder name,

Com.example.hello: Your project's internal package name

HelloWorld: Project name, the name of the package that is displayed after the installation program is installed

Cordova Creation Instructions:

Cordova Create Hello Com.example.hello HelloWorld

The parameters are the same as the phonegap.

In general, Cordova may be a little longer when you create a project

After execution, the project will be created under the appropriate folder, into the Hello folder, the folder below the directory structure:

The main thing you need to care about here is 3 directories,

Platforms: This directory is used to build individual mobile platform projects, and the project files for each platform generated by the instructions will be generated in this directory

Plugins: This is the Add PhoneGap plugin directory, you add the plugin will be in this directory to save

WWW: This is for storing your Web project, here is our Sencha Touch project, packed with compressed items in it.

In the WWW directory, there is a config configuration, in general, the Cordova instruction to create the project's config in configuration, you can not modify,

However, there are some problems with the PHONEGAP project, you need to manually adjust the configuration in config.

The first thing to do is to adjust the

  <access origin= "*"/>

This is used to configure the network access whitelist, only the domain name configured here to access, PhoneGap 3.5 version of the default is 127.0.0.1, if not configured, will not be able to access the external network

  

<access origin= "127.0.0.1"/>

And the previous version of Config. phonegap,<preference name= "fullscreen" value= "true"/> settings with the Android Androidmanifest.xml in the Windowsoftinputmode will conflict, so if you need the screen can be resized according to the soft keyboard needs to set the fullscreen to false;

After these settings are complete, you can add the required PhoneGap plug-ins to your needs.

2. Add PhoneGap plugin:

On the basis of the above project, we will install the CMD Command tool CD into the Hello project directory, this time can be installed via the command plug-in, where the use of phonegap or Cordova plug-ins To add instructions are the same, but

The official documentation is provided by the Cordova instructions, generally I also copy the paste, so we use Cordova instructions to install the plugin, instruction format

Cordova Plugin Add < plugin name | plugin address >

For example I want to add the official camera plugin that I can perform

Cordova Plugin Add Org.apache.cordova.camera

The corresponding plug-in is generated under the corresponding plugins folder, as shown in:

3. PhoneGap Build Android Project

Next we create the Android platform project, using the PHONEGAP instructions, we only need to execute the following command

  

PhoneGap Build Android

  

If you use the Cordova directive, you need to add the corresponding platform, the following procedure is performed

Cordova Platform Add Android

  

This adds an Android project and then executes the

  

Cordova Build Android

After successful execution, the plugins in the Android project will be added into the project.

The build requires a compatibility issue with the Android SDK version of the Cordova build, and if the build is faulty, the Android SDK version may need to be updated.

If the compilation succeeds, it will appear as shown.

4. Import the Android project via Eclipse and export the APK package

(1) Open the Eclipse development tool and Open File->import, which pops up a window as shown in

Double-click the Red box, import the compiled Android project, continue to select File->export after successful import, select the default exported project, next you can create the secret key (custom), and finally you can export an APK package.

Phonegap (Cordova) Create a project and package build APK package with Eclipse development tools

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.