Build Android programs with Cordova (PHONEGAP)

Source: Internet
Author: User
Tags install node

Mobile terminal development with the popularity of smartphones becoming more and more hot, what projects want to move a piece, but it is not easy to learn the control of the various terminals, but in particular, each terminal control and language are different, making this learning become more difficult.

Is there an easy way to quickly build a mobile terminal program and quickly package and use it on every terminal platform? The answer is yes, and this framework is a lot of, this article simple introduction through Cordova (formerly known as PHONEGAP) this platform to build an Android program.

  1. Development environment preparation.
      1. Install the JDK, this step is ignored, the intentional crossing can go to the Oracle website to download your appropriate JDK version. Add the system environment variable "java_home" after installation, The path pointed to is the JDK directory you just installed. and add the PATH environment variable to the java_home, that is, add ";%java_home%\bin" at the end of the PATH environment variable.
      2. download adt-bundle-windows software package, this is the Eclipse development environment where Google integrates the Android SDK. After downloading, you can use it directly after decompression.
      3. install node. js, because Cordova the latest version can be installed directly using node. js. And each development can be updated to the latest Cordova version, so we first install node. js. Available through official website install Cordova, enter "NPM install-g phonegap" in the command line tool, and enter "NPM install again" after successful G Cordova ",
      4. Configure the" Android_home "environment variable to point its path to your ANDROID SDK path, as I have this opportunity set to" D:\Stady\JAVA\Android\Adt-bundle-windows\sdk ".
      5. In addition, ADT (Android emulator) is created by default in the user directory of the operating system disk, if you want to change to another location, you can add an environment variable " Android_sdk_home ", point to the location you want.
  2. Before the formal example, let's verify that the environment is OK, simply by looking at the JAVA/NPM version command to verify that it is normal, such as java–version/npm–version.
  3. After the above steps are OK, we can start the Cordova tour.
    1. In the command window, provide a CD command to jump to the directory where the new project resides. such as CD D:\Stady\JAVA\Android\Project.
    2. Create a new project with command Cordova, the most commonly used command can use the Cordova path package name Project name , as we will create an app for human resources, referred to as HR, the command to create a project can be used as Cordova CR Eate hr HR, after the command is executed, our project file is probably as shown.
    3. Cordova is a cross-platform mobile terminal solution, the directory of platforms will be unique to each platform file resources, currently because we have not added any platform to go in, so this directory is temporarily empty. This article mainly introduces the development of Android environment, other platforms ( IOS,WP, etc.) I have not tried, but the feeling should be similar.
    4. After entering the project solution directory, add the Android platform via the Cordova Platform add Android command. Wait a moment until you see as shown.
    5. At this point, we will be able to see the Android platform we just added as shown in entering platform.
    6. After completing the above steps, our basic work is done, and then we use Eclipse in adt-bundle-windows to open the project we just created. Import the project we just created with the import command in Eclipse.
    7. After the import, our project in Eclipse effect as shown, a total of two projects, Cordovaapp-cordovalib for the Lib project, HR for our work project. In this project, there is currently only one hint file in the assets directory, You can show our project files by removing the file filter by the helper method of this hint file.
    8. Next we can try to look at the index.html file, this is our program Portal display interface, we can simply retrofit, assuming the following is shown below.
    9. Because it's just a test project, after the transformation, we run the project through the simulator. Probably like this. It is clear that the interface our app shows is our index.html content. We go back to our Project Solutions directory and navigate to Platform\android \ bin directory, you can see here is a hr.apk file, I believe you have guessed what this file is, you may wish to copy this file to the phone after installation run to see what the situation.
    10. After the above steps, I think you should be able to understand how to use Cordova to do Android projects. You can try it on your own.
  4. In the above we briefly introduced the use of Cordova to quickly build an Android development project, the example is introduced here, we will learn how to use the jquery mobile +html5+ with a real project HR. Cordova to develop real app programs.
    Extra, I was just beginning to learn this stuff, so the text will inevitably write omissions, welcome you point to learn together. Common improvement.

Build Android programs with Cordova (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: 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.