PHONEGAP environment configuration and basic operation

Source: Internet
Author: User
Tags android sdk manager

first, the development environment configuration: 1, Tool environment installation:Install Java SDK version 1.6 or later, Android development Tools, ant, System variables add after pathadded name Java_home value for JAVA installation path C:\Program files\java\jdk1.7.0_21
Added name Ant_home value for ANT installation path C:\Program Files (x86) \apache-ant-1.9.3
To modify the value of a Path's dependencies
Keep the original value, add it on the back side;%java_home%\bin\;%ant_home%\bin\; SDK installation catalogue \tools\; SDK Installation Catalogue \platform-tools\Reference: Http://jingyan.baidu.com/album/adc815136c6cf5f723bf7389.html launching an Android virtual machine in Eclipsewindow > Android Virtual Device Managerhttp://jingyan.baidu.com/article/19192ad84c8357e53e5707e7.html run your own project in eclipse:Project Right-click > Run as > Android application
2, installation Phonegap|cordova:NPM install-g Phonega
NPM install-g Cordova
WIN8 Error: CB () never called
Workaround, edit the. NPMRC command as follows:
Vim ~/.NPMRC
Registry = http://registry.npmjs.vitecho.com
second, the basic operation:Cordova and PhoneGap relationship: Apache Cordova is PhoneGap's contribution to Apache after the open source project, is extracted from the PhoneGap core code, is to drive PhoneGap core engine. You can help him imagine a relationship like WebKit and Google Chrome.The explanation: Cordova is a mobile application development framework that you can use to make apps based on the web code. Phonegap Build is an online packaging tool that you can use Cordova to write to Phonegap Build,phonegap build and package it online as an app. What we are talking about now is PHONEGAP, which is actually Cordova, and the PhoneGap (PHONEGAP) that was actually acquired by Adobe Home), is now PhoneGap Build, (IPhone, Android SDK Service) and Cordova (Apache Cordova).
for the actual problem you are facing, it is necessary to do not need phonegap build function, need not be packaged online. the PHONEGAP command will be interpreted as the corresponding Cordova command.
Official documents:http://docs.phonegap.com/en/edge/guide_overview_index.md.htmlhttp://cordova.apache.org/Http://cordova.apache.org/docs/en/3.4.0/guide_overview_index.md.html#OverviewCordova Plug-in: http://plugins.cordova.io/#/support for Plug-in functions of each system: Http://cordova.apache.org/docs/en/5.0.0/guide_support_index.md.html#Platform%20Support
1, PhoneGap create the project:PhoneGap Create MyApp
CD MyApp
PhoneGap run Android (after executing this command will launch Android emulator to preview)
The first PhoneGap wrote a program that appeared.
There will be 5 folders in the MyApp directory, and the packaged works are placed in platforms.
Folder interpretation Seephonegap Environment Configuration and basic Operation

2, Cordova create the project: Create command: Cordova create MyApp com.yourname.myapp MyApp
Access project : CD MyApp
Add platform Support :
Cordova Platforms Add iOS
Cordova Platforms Add Android
Cordova Platforms LS
Add Plugins:
Cordova Plugin Add Org.apache.cordova.device
Cordova Plugin Add Org.apache.cordova.console
Cordova Plugin ls
Compiling code (packaged app):
Cordova Build Android
To run the code:
Run on the emulator (provided that the AVD is created)
Cordova emulate Android
Windows convert command conflict, direct "Cordova emulate Android" will be reported error:spawn ENOENT, need to start the simulator first.
Run in Browser:
Cordova serve Android
Browser access address: Http://localhost:8000/, you can debug the page like debugging the layout of the app. If the Cordova native API call is used in the app, the following dialog box pops up:
Install directly to the real machine via USB:
Cordova Run Android
Error: Error:please install Android target: "Android-22" This is mainly not installed and the current Cordova corresponding requirements of the Android Platform SDK, this can be solved in 2 ways,
Open ADT, open the Android SDK Manager, and install the SDK for the corresponding platform. (Refer to the next section)
Open the following directory, which may have different version numbers,
Project Path \platforms\android\project.properties
Modify
Target=android-19
You can change this to a flat andriod that you have now installed, or you want to specify an Android platform.
Once this problem is resolved, the example project above can be generated and then imported with ADT Eclipse, agreeing to run to see the effect in the AVD. problem: Change target to android-19 after the build command error, or confidently upgrade to the ANDROID22 version of it:(
Android SDK Manager cannot update the solution at home(1) Launch Android SDK Manager, open the main interface, select "tools", "options...", pop up the "Android SDK manager-settings" window;
(2) in the "Android SDK manager-settings" window, fill in port"and 80 in the"http proxy server"and"http proxy mirrors.neusoft.edu.cn input boxes, and select "for Ce https://... sources to be fetched using http://..."check box. Click the "close" button to close the "Android SDK manager-settings" window and return to the main screen after Setup is complete.


(3) Select "packages", "reload". Cordova The default installation is Android22, install the Android22 method:Tools > Manage add-on Sites > select the appropriate version to install
3. Eclipse Operations(1) New Projectfile > New > android Application project(2) Import ProjectRight-click Import > Android (existion Android Code into Workspace) > select established project directory(3) Run project (cannot refresh in emulator after project file modification)Project Right-click > Run as > Android applicationor
once the project file has been modified, run as can update the app.the files in the PhoneGap project simulator have not been updated: (
three, packaging app:The command is as follows:PhoneGap Build android (apk build directory in Platforms\android\ant-build)or Cordova build android (build directory platforms\android\build\outputs\apk)
Iv. managing Apps in Android Simulator:1. Install app in simulator (1) running the project in Eclipse installs the app in the emulator, and the app that runs with the Run command will also be installed in the emulator. (2) Enter the directory where the app is located and run the command: adb install xxx.apk 2. Uninstall app in simulator Long Press the item icon in the simulator to uninstall, drag to app info to stop running the app


PHONEGAP environment configuration and basic operation

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.