Installing Android Studio + SDK and ROSJava Environment:

 

Installing Android Studio + SDK and ROSJava Environment:

ROSJava is an opensource project in pure Java for inegrating ROS with Android Development Environment.

*All the instructions provided below have been tested on Ubuntu 12.04 LTS. They might change for other Linux distributions. For example, the same installation procedure will not work on Linux Mint. That would require building from the source (a method which the ROS website does not recommend).Installation in Ubuntu 12.04 is fairly easy due to the availability of precompiled debs (debian files)*

  1. Android Studio and SDK

    The new android development (hydro and beyond) is based on google's Android Gradle Plugin &
    Android Studio which will be replacing the ADT & Eclipse. It is available for download on
    Windows, Linux and MacOSX. The following steps cover the installation procedure in Linux Ubuntu:

     

    1. Prerequisites:

      You will need a Java development. There are two available kits; openjdk and Oracle Java
      Development Kit
      . Android Studio will give you a warning on start up if you use
      openjdk, but we just ignore it right now. Read below if you want more information
      on which jdk to use.

      To install openjdk:

      $ sudo apt-get install openjdk-6-jdk

      Why we might need an Oracle JDK:
      According to the ROS website:
      Android studio shows you a healthily fat warning when you start it that recommends you use oracle's jdk, or else it will be all doom and gloom. We haven't had major issues with the openjdk yet, although anecdotal evidence suggests that if you are short on memory the Oracle JDK is better.”

      If you do want to install oracle's jdk on ubuntu:

      $ sudo add-apt-repository ppa:webupd8team/java -y
      $ sudo apt-get update
      $ sudo apt-get install oracle-java6-installer
      # Switch back to openjdk anytime with sudo update-alternatives --config java
      
    2. Installation:

    • If you're using a 64 bit machine, the ia-32 libs have to be installed.

      $ sudo apt-get install ia32-libs
    • Download android studio and untar it under /opt/android-studio (recommended). Add to your path. If you put the files anywhere other than /opt/android-studio you will have to tweak the following command to suit:
       

      $ echo export PATH=\${PATH}:/opt/android-studio/sdk/tools:/opt/android-studio
      /sdk/platform-tools:/opt/android-studio/bin >> ~/.bashrc
      
      $ echo export ANDROID_HOME=/opt/android-studio/sdk >> ~/.bashrc
    • Open up the Android SDK Manager with the command:

      $ android
    • In the SDK Manager make sure you have installed

    Under Tools:

    1. Android SDK build tools 19.0.1

    Android API 19 / 18 / 17 / 16 /15 / 13 / 10 / 7

    (Unclick the TV addons from API 13)

     

    • SDK versions Android 2.3.3 (API 10), Android 3.2(API 13) and Android 4.2.2 (API 17). It's not a whim to install three different versions: we use API 10 for Gingerbread compatible libraries, API 13 for Honeycomb libraries (that cannot work on Gingerbread) and API 17 because is the latest at the time of this writing. You can open Android Studio with the command:

      $ studio.sh

      Now we are equipped with Android Studio and SDK and now we can start installing the ROS debian packages and libraries

  2. Installing ROS & ROSJava Debians

  1. Debian Installation
    There are pre-compiled debians available for a lot of packages for Ubuntu which makes the installation extremely easy. We'll need catkin, ros (for the setup.bash variables) and a few message packages to ensure it all compiles. There are several other packages which we might need during the course of the project. Those packages can be installed later as and when we need them.
     

    > sudo apt-get install ros-hydro-catkin ros-hydro-ros ros-hydro-common-msgs
  2. Wstool:
     

    > sudo apt-get install python-wstool


    When this is not possible, fall back to pip:
     

    > sudo pip install -U wstool
  3. Set up some chained catkin workspaces to modularise the builds and save some compile times.
     

    > mkdir -p ~/rosjava
    > wstool init -j4 ~/rosjava/src https://raw.github.com/rosjava/rosjava/
    hydro/rosjava.rosinstall
    > source /opt/ros/hydro/setup.bash
    > cd ~/rosjava
    > catkin_make
  4. Now the source android workspace:
     

    > mkdir -p ~/android
    > wstool init -j4 ~/android/src https://raw.github.com/rosjava/rosjava/
    hydro/android_core.rosinstall
    # or if you want the android_apps/android remocons repos as well:
    # wstool init -j4 ~/android/src https://raw.github.com/rosjava/rosjava/
    hydro/android_apps.rosinstall
    > source ~/rosjava/devel/setup.bash
    > cd ~/android
    > catkin_make


     

  1. Now we have a fully fuctional Android Studio integrated and SDK integrated with the ROSJava development environment. The next post shall cover integrating the ROS Sensors Driver with the smartphone, running the ROS master node on the laptop and reading the sensor values from the smartphone.