PhoneGap(1)Introduction and Installation

PhoneGap(1)Introduction and Installation

1. Installation
> sudo npm install -g phonegap

>phonegap -v 3.3.0-0.18.0

Update the phone gap
>sudo npm update -g phonegap

2. Simply use PhoneGap
>phonegap create easyphonegap com.sillycat.easyphonegap HelloWorld

Build IOS
>phonegap build ios

Build Android
>phonegap build android

2.1 Working on iOS
Try to run on iOS
>phonegap install ios
But I get some error message, so I install ios-sim
>sudo npm install -g ios-sim
But still the command line open the emulator, I do not want emulator, it is slow, I prefer to test on real device.

Try to run on real device
>phonegap install ios --device
get error message, ask me to install ios-deploy

>sudo npm install -g ios-deploy
>ios-deploy -V
1.0.4

After that I try these commands, but nothing works.
>phonegap install --device ios -V
>phonegap run --device ios -V

My iOS’s name is Sillycat, so I try this command
>phonegap install ios --device Sillycat -V

I can install the app there, but it is not running after this command install/run. So I try this 

>"/Users/carl/work/phonegap/easyphonegap/platforms/ios/cordova/run" —device Sillycat

Error Message
(lldb) run error: a process is already being debugged
Process 0 connected

Solution:
>lldb --version lldb-300.2.53

Finally, I use my Xcode to run and debug the app there. The command line only successfully install the app on my device.

2.2 Working on Android
Try to run on Android
>phonegap install android
Not Good
[phonegap] no device was found
[phonegap] trying to install app onto emulator


But I am sure I have the devices.

>adb devices List of devices attached SH0CHPL12484    device

>phonegap run android --device SH0CHPL12484 -V

Error Message
[phonegap] Running app on platform "android" via command "/Users/carl/work/phonegap/easyphonegap/platforms/android/cordova/run" --device    [error] An error occurred while running the android project. /Users/carl/work/phonegap/easyphonegap/platforms/android/cordova/node_modules/q/q.js:126                    throw e;                          ^ ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: pkg: /data/local/tmp/HelloWorld-debug-unaligned.apk
Failure [INSTALL_FAILED_OLDER_SDK]

Solution:
There are 2 ways to solve this problem. Change a latest android device or change the mintarget version in android manifest file to a lower version.


References:
http://mobile.51cto.com/android-273486.htm
http://mobile.51cto.com/hot-276266.htm

http://yunfeng.sinaapp.com/?p=32
http://www.ibm.com/developerworks/cn/web/1108_rendy_phonegap/index.html

http://phonegap.com/install/

Tips
http://docs.phonegap.com/en/edge/guide_overview_index.md.html#Overview
http://phonegap.com/developer/

http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-Line%20Interface

http://cordova.apache.org/

你可能感兴趣的:(PhoneGap)