The Android SDK and Development Tools

July 17, 2010

FINALLY!  It only took about 2-3 days for me to get this thing working.  This post is going to outline what I did.  The reason being that I might have to go through this process again sometime in the future and also finding help online was not that easy.

STEP 1: Get the right version of Eclipse. At the time of this post Eclipse 3.6 is out, well you don’t want this version since Google has said that there are problems with this version and their SDK. Instead you want to get Eclipse 3.5.2, just to the download page and select to see older versions of Eclipse, then fine 3.5.2 and download. Depending on your connection this shouldn’t take too long.

STEP 2: Install Eclipse. For this step just see my previous post, all the steps are exactly the same even though you are installing Eclipse 3.5.2 and not Eclipse 3.6.

STEP 3: Download the Android SDK. Just enter Android SDK into Google and the page you want should be the first link. Download the Linux version (I assume you are using Linux, though Mac users might also be able to find some help in this post). It’s a pretty “small” file so it shouldn’t take that long to download. Unpack the file with tar -xzf <filename>. Then save the extracted directory somewhere, we shall refer to this location as SDK_HOME.

STEP 4: Install the SDK. First you will want to add SDK_HOME/tools to you PATH. To do this just open up a terminal and enter, PATH=$PATH:SDK_HOME/tools.
Remember that SDK_HOME is the full path of where you saved the extracted directory. Now while you are still in the terminal run;
cd SDK_HOME/tools
./android

This will open up and SDK manager UI. Select available Software (or something along those lines) and then select everything in the right column. You don’t need to select everything but it doesn’t hurt, since I’m not sure exactly what you need since I didn’t read all the options. Once you have done this click install and then wait a while for everything to be downloaded and installed. At the end of this process you will get a window prompting you to restart the manager, please do so.

STEP 5: Open Eclipse. This step might not be necessary for some people but it was for me and I figure that it will be for others. So as to avoid any potential future problem please do as instructed.
Go to Help > Install New Software…, then click the Add button to the right of the drop down menu. In the box that appears enter Galileo Software Repository as the name and http://download.eclipse.org/releases/galileo/ as the location, and then hit OK. Then in the filter box (the text box below the drop down menu) enter “server”. You should see an item called “WST Server Adapters…“, select this item (or everything in the same group if you want) and then press next. Agree to the license and then hit finish. If at any point you are asked if you trust the source of the software say yes (or whatever the appropriate option is).

STEP 6: Integrate the Android SDK into Eclipse. Once again go to Help > Install New Software…, and click the Add button as before. This time in the name field enter Android Development Plugin (or any appropriate name), and in the location enter https://dl-ssl.google.com/android/eclipse or http://dl-ssl.google.com/android/eclipse. Now select everything and click next. Agree to the license and say that you trust the software source if asked at any point.

STEP 7: Tell Eclipse where to find the Android SDK. Go to Window > Preferences. In the left column select Android, if you don’t see Android then a previous step did not work as intended and I’m not sure how to help you (I suggest removing everything relating to Android and Eclipse from you system and starting over). Now select the text box for the location of the SDK, enter SDK_HOME (hopefully you remember where it is).

STEP 8: Create an Android emulator. Go to Window > Android SDK and AVD Manager. On the right select New and enter a desired name for your emulator and size for the virtual SD card.

If everything went as planned you should now be able to start development.  For tutorials just search Google or the Android SDK site.

The following site was pretty helpful when I encountered problems installing the Android Development Plugin.  Additionally, this YouTube video is pretty useful and documents all the steps, other than the method you should use to install Eclipse.

Advertisements

Eclipse

July 16, 2010

I’m sure that you have heard of Eclise.  If not then all you need to know is that it is a very popular (and for a good reason) IDE mainly for Java.  However, it does also have C/C++ support, but it is mostly used with Java.

As you know, I’m not big on programming in Java.  But I recently purchased a Nexus One phone, and the IEEE SECon got me a little interested in Android application development.  I don’t plan for anything I make to be widely distributed, but rather just for personal use.  In any case, I would still need a place to create my programs.  Sure this can be done with a normal text editor and the command line but why bother with that when Eclipse and the Android SDK make it so simple?

I’m going to talk about getting and installing Eclipse onto you system (which I will assume to be Ubuntu).  Sure you could just run sudo apt-get install eclipse but this way assumes that you are using the OpenJDK version of Java and not Sun’s. So if you are using SunJava, which it seems most people do, then this how-to is for you.

First head over to the Eclipse site and download the IDE. To find the site just use Google and then do some reading and clicking, so there is no need for me to post a link. If you can’t get past this step then you probably shouldn’t be thinking about using Eclipse.

Next we will open the package you have just downloaded and then move it to the /opt directory. To do this just run the following sequence of commands:

tar xzf <filename>
sudo mv eclipse /opt/eclipse
cd /opt
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`

The chown command changes the owner of a file/directory, if you have been reading this blog then you should be able to figure out what the other commands do.

Next we will add eclipse executable to your path.

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudoedit /usr/bin/eclipse

then add this to the file

#!/bin/sh
#export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="/opt/eclipse"

$ECLIPSE_HOME/eclipse $*

I’m not all to sure exactly what the touch command does but you can look that up yourself (either online or with man).

Finally, the “most important” part; creating a GNOME-menu icon. This is something that would normally be done when you use the apt-get method.


cd /usr/share/applications
sudo nano eclipse.desktop

And enter the following into the created file;

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

All the stuff entered into the file makes perfect sense, so if you ever wanted to make a menu item for any other program you now know how.

All of these steps can be found at http://flurdy.com/docs/eclipse/install.html.


Acrobat Reader

March 25, 2010

Well long (though interesting) story short I had to reinstall Ubuntu (still version 8.04).  I’ll give you th long story soon enough, but first here is something that might be useful.

At first I was fine with using Evince for viewing PDF files but there are just a few things that Acrobat does that I like.  Overall I still prefer Evince since it is much faster at loading and not “bloated” with features that I won’t ever use.  Regardless I still needed to install Acrobat.

Normally you would be able to just run sudo apt-get install acroread, but for some reason acroread is no longer in the Ubuntu list of provided programs.  So I had to do some work on Google.  Sure finding Acrobat was easy but I needed to make sure that it would work on an 64bit OS.  As usual, a pain in the ass.

I won’t go into all that I tried, I’ll just tell you what worked.  First go to this site http://get.adobe.com/reader/ and choose the appropriate OS (Linux) and the .bin file.  Apparently choosing the x86 version is fine.  Assuming that it was downloaded to your desktop run chmod u+x *.bin, where * is whatever the file is called.  Then finally run sudo ./*.bin.  Make sure to add the sudo or you’ll run into some issues (I’ll let you see what kind).  During the install when asked where to store the file(s) make sure to pick a location that is in your PATH.  I chose /usr/bin but I suppose that any location will work.

Now you can run acroread and be on your way.


Choosing the Right $PATH

August 23, 2009

Sorry for the long delay, but I have been busy with getting ready for school again and moving into my new apartment.

This is in some ways a continuation of my post Changing Modes.  As pointed out in one of the comments (thanks to Miorel) some people might wonder why you would have to type ./hello_world instead of just hello_world in order to execute the Perl script.  Well I though about this for a second and thought, “Well to run a script that isn’t one implemented by the OS you must place ./ before it.  This tells the OS that you are trying to execute a file.”  For example, if you want to run Firefox you just need to type firefox and not ./firefox.  If you are curious-and you should be-and enter ./firefox into the terminal you should get the following message, “bash: ./firefox: No such file or directory” (unless you for some reason have a file or directory called ./firefox, but why would you?).

Though that might answer might be good enough for some, I wanted to know why this was so, and if it was possible to change it so that you would only need to type hello_world (and not ./hello_world).  This is where $PATH comes into play.  I am going to try my best to explain this, and will also provide links to other sites for further reference.

To begin with here is a one line definition-which sadly isn’t mine, but gets the point across-of what the PATH variable is.

PATH is a list of directories where commands are looked for.

So when I type echo $PATH into the terminal I get the following:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Returning to our original example; if you were to type hello_world into the terminal. The OS would first look for a command (a file with the x bit set) with that name in /usr/local/sbin. If one is found it is run, if not it continues onto /usr/local/bin, and so on.

Now if we would like to only have to type hello_world, all we would have to do is add its directory to the PATH variable. Suppose that our script is in the directory /Mine. First I will show you the WRONG WAY to do this. Then two different correct ways (though I am not all that sure about which is better to use as of yet).

THIS IS THE WRONG WAY!!! $PATH=/Mine
This is wrong because it will replace the original PATH variable with /Mine, and I am sure that you don’t want this.

Correct way #1: PATH=/Mine:$PATH
Correct way #2: PATH=$PATH:/Mine

As you can see, the first one will add /Mine to the beginning, and the seoncdd to the end of the PATH.

Here are two sites you can visit if you wish to learn more about the PATH variable. http://www.faqs.org/docs/Linux-mini/Path.html and http://www.troubleshooters.com/linux/prepostpath.htm