Hello PhoneGap – from xUbuntu 12.04 Live CD

Install PhoneGap development environment and emulator from scratch. Start writing Android applications with Javascript and HTML.

Guru version

  • Hello Android
    • $ sudo apt-get -y install ia32-libs eclipse
    • Eclipse: Help: Install New Software. https://dl-ssl.google.com/android/eclipse/. Install Android 2.2.
    • New Android Virtual Device? Target: API Level 8. Name: api8. Run Android Hello World in emulator.
  • Hello Cordova

For the rest of us, read on for details…

Boot Live CD

Boot from xUbuntu 12.04 LTS 64bit Live CD. Accessories: Terminal. ‘setxkbmap fi’

Hello Android World

Eclipse with ADT plugin

$ sudo apt-get update && sudo apt-get -y install ia32-libs eclipse

Development: Eclipse. Workspace? Use this as default, OK.
Help: Install New Software. Google “install android eclipse plugin” if you have to find the URL without this tutorial.

https://dl-ssl.google.com/android/eclipse/

Enter. Developer tools: check. Next. If install doesn’t start in a minute (“Calculating requirements and dependencies.”), stop it (red stop button) and start again. I accept license agreements: Yes. You are installing … unsigned: Yes. Restart eclipse? Restart.

Install Android 2.2 SDK with Wizard

Install new SDK: Install Android 2.2: Yes. Install latest: no. Send usage statistics to Google? No. Choose packages to install: Accept all.

New Android Project

File: New: Project… Android: Android Application Project.
Application Name: Hello Android. Next, next, next, next.
Install dependencies: Install/Upgrade, Accept All.

Running in Emulator

Project explorer (left pane): Hello Android: src: MainActivity.java. Double click to open in editor. Run: Run. Android Application.
Add new Android Virtual Device? Yes. Launch new. Manager… New… Name: api8 Target: …API Level 8… Create AVD Start. Launch. (Boots for 1-2 min showing android logo) Close AVD manager windows.
Run: Run
Emulator shows white screen with text “Hello world!”.
You have now successfully run Android Hello World. Well done!

Hello PhoneGap

File: New: Project: Android: Android Application
Project Name: Tero Runs Cordova. Next, next.. Finnish.
Following paraphrases the official guide: Phonegap.com.: Developer: Get Started. Gettings Started with Android.

$ cd; cd "workspace/Tero Runs Cordova/"
$ mkdir assets/www/

phonegap.com: Download PhoneGap. Download (22.2mb) [sic]

$ wget https://github.com/phonegap/phonegap/zipball/2.1.0
$ unzip 2.1.0
$ rm 2.1.0
$ cp -i phonegap*/lib/android/cordova*.jar libs/
$ cp -i phonegap*/lib/android/cordova*.js assets/www/
$ cp -ri phonegap*/lib/android/xml/ res/
$ rm -r phonegap-phonegap*/

Ecplise Project Explorer (left pane)̣ F5 refresh (so that libs/cordova*.jar shows). libs: right click: Build Path: Configure Build Path… Libraries: Add JARs: Tero Runs Cordova: libs/cordova*.jar.

src/MainActivity.java:
  import org.apache.cordova.*;
  extends DroidGap
  super.loadUrl("file:///android_asset/www/index.html");

AndroidManifest.xml: Copy paste from Cordova Gettings Started with Android. Lot of uses-permission. ctrl-shift-F to format (autoindent). Skip configChanges for now, as it seems to give an error that prevents compiling.
assets/www/ : New: File: index.html. index.html: right click: Open with: Text editor
Google “Cordova API”. Click Device: Full example. Copy-paste index.html code.
MainActivity.java: Run: Run: Android Application. (You have to be editing MainActivity.java for run to work.)
Auto Monitor Logcat? Yes. higher than: error.
Emulator shows black text on white background: Device name: sdk … Device version: 2.2.
Hello Cordova was succesfully run. Your Cordova/PhoneGap development environment is now working.
Have fun coding your apps in Javascript and HTML!

Posted in Uncategorized | Tagged , , , , , , , , , , , | 2 Comments

2 Responses to Hello PhoneGap – from xUbuntu 12.04 Live CD

  1. “R cannot be resolved” – virhe kääntäessä Hello Androidia.
    Mahdollinen ratkaisu
    http://stackoverflow.com/questions/16642604/eclipse-error-r-cannot-be-resolved-to-a-variable

  2. $ ./android-sdks/tools/android
    Tools: check. Install 4 packages. (Especially, Android SDK Build Tools is needed)
    Close and open Eclipse. Run your Android app.