Skip to content

Instantly share code, notes, and snippets.

@regdog
Last active May 5, 2016 05:57
Show Gist options
  • Save regdog/2d22d6a6415a8d46bbb7 to your computer and use it in GitHub Desktop.
Save regdog/2d22d6a6415a8d46bbb7 to your computer and use it in GitHub Desktop.
How to Install PhoneGap in Ubuntu 12.04 LTS
# 1. install java
# 2. install ant
# 3. install npm and nodejs
# 4. install android sdk
# 5. install phonegap
# 6. create a hello world phonegap app
# 7. lunch android avd(emulator)
# 8. run the app
# 9. add pluins
# 1. install openjdk6
sudo apt-get install default-jre
sudo apt-get install default-jdk
# 1. or install openjdk 7
sudo apt-get install openjdk-7-jre
sudo apt-get install default--7-jdk
java -version
# if multi-java, set default java
sudo update-alternatives --config java
# set JAVA_HOME
nano ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
# 2. install ant
sudo apt-get install ant
# remove error "Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar"
sudo apt-get install openjdk-6-jdk
# set ANT_HOME
which ant
nano ~/.bashrc
export ANT_HOME=/usr/bin/ant
export PATH=$PATH:$ANT_HOME/bin
source ~/.bashrc
# 3. install npm & nodejs
sudo apt-get install npm
# Get the latest nodejs (by installing ‘n’ and running that
sudo npm update npm -g
sudo npm install n -g
sudo n stable
# Alternatively, install the latest Node.js & NPM
git clone https://github.com/joyent/node.git
cd node
# 'git tag' shows all available versions: select the latest stable.
git checkout v0.7.8
# Configure seems not to find libssl by default so we give it an explicit pointer.
# Optionally: you can isolate node by adding --prefix=/opt/node
./configure --openssl-libpath=/usr/lib/ssl
make
make test
sudo make install
node -v # it's alive!
# Luck us: NPM is packaged with Node.js source so this is now installed too
curl -L https://npmjs.org/install.sh | sudo sh
npm -v # it's alive!
# 4. install android sdk without eclipse
# 4.1 download Android SDK Tools Only (android-sdk_r22.6.2-linux.tgz) from android developer website
# 4.1 Go to the extracted folder, you will find a folder called “tools”. From the tools folder, double click the script file called “android”.
# 4.1 Click Execute to start Android SDK Manager. Install Platform-tools, Android platforms and other add-ons
# Set android sdk to PATH
nano ~/.bashrc
export PATH=$PATH:/home/sk/android-sdk-linux/tools
export PATH=$PATH:/home/sk/android-sdk-linux/platform-tools
source ~/.bashrc
# 4.2 create android avd
android avd
# create avd
# 5. install PhoneGap
sudo npm install -g phonegap
phonegap -v
# 6. create a hello world app
cd ~/projects
phonegap create hello com.example.hello HelloWorld
# 7. lunch android avd
android avd
# start using your Android phone from the Android emulator.
# 8. run the app
cd hello
# You should see the app compile and install on the emulator.
phonegap local run android
# You can do the compile and install steps separately:
phonegap local build android
phonegap install android
# 9. deploy to a real phone
# plug in Android phone via USB, select “USB debugging” in the Developer section of the settings on the phone, and the app will be installed on the phone when you next do “phonegap install…”
# 10. add plugins, optional step
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
@imyaman
Copy link

imyaman commented Dec 30, 2014

s/default--7-jdk/openjdk-7-jdk/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment