Ubuntu, Eclipse, Android SDK and Cordova install
This is a guide on how to install an Apache Cordova development machine with the Google ADT Eclipse bundle, the Android SDK, and all dependencies on Ubuntu (or Lubuntu) 14.04. I strongly recommend using 32 bit development machine/vm. This guide was made on: 6/13/2014 for Ubuntu/Lubuntu 14.04
Contents
Installation
- Platform: Linux x86 Virtual Machine
- OS: Ubuntu, Lubuntu 14.04
- Cordova: 3.5.0
- Eclipse:
- ADT:
- Android SDK: 22.6.4
- Android SDK Platform Tools: 19.0.2 and 19.1
Install Java Dependencies
You can choose from JDK 6 or 7 (I use JDK 6 as of this date):
sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin sudo apt-get install openjdk-7-jre openjdk-7-jdk icedtea-7-plugin
Add JAVA_HOME to environment
Edit your .bashrc file and add this line:
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386
- Replace with your java bin folder!
Install ANT
Note: you need java setup and JAVA_HOME setup in .bashrc for this to work
sudo apt-get install ant
Install Cordova
This method uses apt-get rather than the old method with node.js and git. I do not have any comment on which is better yet.
sudo add-apt-repository ppa:cordova-ubuntu/ppa sudo apt-get update sudo apt-get install cordova-cli
Download Eclipse + SDK
This comes with the Android SDK, and Eclipse. This link is version 22.6.2 but check for more recent versions. Source: http://developer.android.com/sdk/index.html
32-bit v22.6.2
wget http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86-20140321.zip unzip adt-bundle-linux-x86-20140321.zip cd adt-bundle-linux-x86-20140321 mv -f eclipse ~/ mv -f sdk ~/android-sdk-linux
This will download the ADT bundle, Eclipse, and the Android SDK. They will be located in your home directory after moving the files out of your unzipped folder.
Add Android SDK and Eclipse to PATH
Add these lines to your ~/.bashrc (at the end of the file):
#Android DEV export PATH=${PATH}:~/android-sdk-linux/tools export PATH=${PATH}:~/android-sdk-linux/platform-tools export PATH=${PATH}:~/eclipse
Run SDK and update
Open a terminal or the run prompt and type:
android
You will need to check items you need on this list and update or install them.
Required items from the SDK:
- Android-19 4.4.2 (or the current latest)
- Android-10 2.3.3 (If you want a test device for older phones)
- Android SDK Tools
- Android SDK Platform-Tools
- Android SDK Build Tools
- Android Support Library (in extras)
Setup Eclipse
You must define the location of your android SDK toolset when Eclipse first opens.
Preferences > Android > SDK Location /home/dev/android-sdk-linux
Replace dev with your username
You may be asked twice to locate your SDK. Same folder both times.
Testing Setup
Create a new cordova project
Make a directory for your projects
mkdir cordova-projects cd cordova-projects
Create a new project with Cordova
This command creates a new project with directory structure
cordova create hello com.example.hello HelloWorld
- hello - this is the folder name to be created
- com.example.hello - this is the name of the package in reverse DNS order
- HelloWorld - this is the name of the project and soon-to-be app
Add Android system to Cordova project
cd hello cordova platform add android cordova build
Import into Eclipse
Open Eclipse
eclipse&
Import existing project into workspace
File > Import > General > Existing Project into Workspace
Choose the android folder created with cordova-cli
~/cordova-projects/hello/platform/android
Add gen folder and src folder to build
Right click project > Properties > Java Build Path > Source > Add Folder Check the 2 folders "gen" and "src" Choose NO to remove the project as a source
Remove Exclusions from the project (to see the www folder)
Right click project > Properties > Resource > Resource Filters Remove the filter containing "assets" and "www"
Build cordova.jar
This is the step that is most confusing and least documented. You will get a ton of errors whenever your app tries to use Cordova because it requires a .jar java file called cordova.jar. This used to come with PhoneGap and Cordova in older packages, but now you have to build it. Here is how.
- Get the most recent cordova from the distro page for Android: https://www.apache.org/dist/cordova/platforms/
- Open a terminal to the place you unzipped
cd cordova-android/framework android update project -p . -t android-19 (use the highest Android version)
- build the jar file
ant jar
Now select the jar and place it in a safe place for later use!
External Links
- Google Android SDK - Official Site
- Gaggl - Manual Eclipse Install (used for the java deps)