Get ready to set up the Android development environment and to create a PhoneGap app using Android as target platform. Follow these steps:
$ cd PHONEGAP_ROOT/lib/android/bin
$ export PATH=$PATH:~android-sdks/tools/$ export PATH=$PATH:~/android-sdks/platform-tools/
./create
from the bin
directory of android:$ ./create ~/PhoneGapProjects/PGGettinStarted/ch01/android com.gnstudio.samples.cordova.hello HelloPG
The tool actually needs three parameters: the path of the project files, the package of the project, and the name of the project. The tool creates an Android project including the folders and the files needed to debug, emulate, and build the PhoneGap app:
|-assets |---www |-bin |---res |-cordova |-gen |-libs |-res |-src
AndroidManifest.xml
file; it's important that the package name and the activity name defined in the files match the arguments used when launching the ./create
command:<manifest xmlns:android="http: //schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan" package="com.gnstudio.samples.cordova.hello" android:versionName="1.1" android:versionCode="5"> <activity android:name="HelloPG" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
www
folder you'll find the HTML/JS/CSS files needed to run the sample PhoneGap app bundled with the binary of the distribution. In order to run the application on the emulator, it's enough to run the app. Open a command-line tool and point to the cordova
folder, define the path to the Android SDK tools, and launch the ./emulate
command-line tool:$ cd ~/the/path/to/your/source/code/ch01/android/cordova$ export PATH=$PATH:~/android-sdks/tools/$ export PATH=$PATH:~/android-sdks/platform-tools/ $ ./emulate
The tool will check whether some virtual devices are already defined and prompt the user to define one if not. If there is more than one device already defined the tool will ask which one to use. When the selected device is loaded into the emulator you can debug the application; when launching the ./debug
tool the app is installed and can be launched from the control panel of the emulator.
You created a PhoneGap project and emulated the HelloPG
app in one of the testing devices configured within your Android SDK.
In order to correctly emulate the app on Windows you have to install the latest Android JDK, the Apache Ant binary, and the Android SDK. After all of those are installed add the path C:Program FilesJavajdk1.7.0_09in;C:UsersYOUR_USERDocumentsapache-ant-1.8.4in;C:Program Files (x86)Androidandroid-sdk ools
to your path system variable. You can access the path system variable by navigating to Control Panel | System | Advanced System Settings | Advanced | Environment Variables | System Variables.
3.145.178.157