Android Development with IDEA on Fedora

Share on Facebook0Tweet about this on TwitterShare on Google+0

IntelliJ Idea is a beautiful, extendable and up-to-date IDE for Linux, Mac OS X and Windows. Its community edition is free and open-source. It also has full fledged Android development support.

In this post I will explain how to set it up on Fedora 17 x86_64 (The steps may differ from distribution to distribution but in general it should give you the necessary tips).

  • Grab the latest community version from here and extract the tarball under /opt:
    # cd /opt
    # tar xvf /home/ozan/Downloads/ideaIC-11.1.4.tar.gz
    # ln -s idea-IC-117.963 idea (This will change according to your version)
  • Now let’s create a symlink in /usr/bin for easily launching IDEA:
    # ln -s /opt/idea/bin/idea.sh /usr/bin/idea
  • Some people reported that they had no issues with IDEA + OpenJDK (Open-Source JDK distributed in Fedora) while developing Android applications but the general consensus is to setup Sun JDK/JRE. Grab the latest JRE and JDK for your architecture from here and install them as root or using sudo(Ignore the errors below):
    # rpm -ivh /home/ozan/Downloads/{jdk*,jre*}
    Preparing...                ########################################### [100%]
       1:jre                    ########################################### [ 50%]
    Unpacking JAR files...
    	rt.jar...
    Error: Could not open input file: /usr/java/jre1.7.0_09/lib/rt.pack
    	jsse.jar...
    Error: Could not open input file: /usr/java/jre1.7.0_09/lib/jsse.pack
    	charsets.jar...
    Error: Could not open input file: /usr/java/jre1.7.0_09/lib/charsets.pack
    	localedata.jar...
    Error: Could not open input file: /usr/java/jre1.7.0_09/lib/ext/localedata.pack
       2:jdk                    ########################################### [100%]
    Unpacking JAR files...
    	rt.jar...
    Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/rt.pack
    	jsse.jar...
    Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/jsse.pack
    	charsets.jar...
    Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/charsets.pack
    	tools.jar...
    Error: Could not open input file: /usr/java/jdk1.7.0_09/lib/tools.pack
    	localedata.jar...
    Error: Could not open input file: /usr/java/jdk1.7.0_09/jre/lib/ext/localedata.pack
  • Now the good part is that IDEA supports an environment variable $IDEA_JDK for setting the JRE. This is nice because we can continue to use OpenJDK in anywhere except IDEA. Create a file called idea.sh in /etc/profile.d:
    #!/bin/bash
     
    export IDEA_JDK="/usr/java/latest"
  • Spawn a new shell so that the new variable is set and launch IDEA by calling idea:
    $ idea
    Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

    As you can see the JRE that we have installed is now in use. We may now proceed to setting JSDK and Android SDK paths through IDEA settings.

  • Go to File->Project Structure in IDEA. Under Platform Settings click SDKs. Click the + sign and select JSDK, point it to /usr/java/latest.
  • Assuming that you already installed the necessary tools from Android Developer Center and downloaded at least one target platform SDK using the tools provided, click the + sign and select Android SDK. Point the chooser to the root folder of Android SDK (The parent folder containing add-ons, extras, platforms, platform-tools, etc.). If you did it correctly IDEA will ask you first for a JSDK version and then a target Android SDK. Repeat this step for each target Android SDK. The final screen should look similar to the one below:

Now you are ready to start with your first Android project. You can follow the tutorial found here. Keep in mind that the tutorials and design guides in developer.android.com are very detailed and well written 🙂

Share on Facebook0Tweet about this on TwitterShare on Google+0