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.


“Shredding a Directory”

January 2, 2010

Well  you are all familiar with the shred command right?  Well if not then I suggest you read the post at this link.  It does a better job than I could ever hope to.  That and I’m just plain lazy, but mostly because it is an amazing post.

So at this point you should have played with the command a little and noticed that it doesn’t let you shred directories.  Well here is a little ‘hack’ to get around that, say hello to the find command.  I’ll probably talk more about this command later, but now I’ll just explain how it can be used in conjunction with shred.

Say you have a directory on your Desktop call Stuff, and you would like to shred it because it contains very sensitive documents (don’t ask me why you stored this on your personal computer).  First go to that directory and do the following:

cd ~/Desktop/Stuff
find -type f -execdir shred [options] '{}' \;
cd .. && rm -rf Stuff

In the [options] field, I normally put either -z or -uz, but that’s just something I like to do.  First of all you should know what the first line here does, so I won’t explain it at all.  The last line first moves you back to the Desktop and then the rm command is used to remove files (in the insecure sense).  Here the -rf options says that you want to run rm recursively (on all subdirectories) and to force remove files.  Now for the second line, where most of the work is done.

find -type f will list all of the normal files (for simplicity non-directories) in the current directory.  After this the -execdir option says to run the following command (shred in this case) on all of the files that were previously found.

There you have it, a nice way to “securely” a directory.


Linux File System: Part 2

September 7, 2009

This is a continuation from part 1, so you might want to read that first in order to get a general idea of what’s going on.  That is  of course you are a somewhat experienced Linux user.

In this part of the series I will be discussing the following directories/partitions: /bin /boot /dev /etc /home.

/home

I will start by discussing the partition that is most familiar to most new users, /home.  First you should know that Linux, unlike Windows, was originally designed to be a multi-user system.  Thus in the home directory you will find a set of directories, one for each user.  Every user (along with the system administrator) can access their directory by entering cd /home/[user name].  Each user’s home directory contains their own personal files in addition to their personal settings for programs.

/bin

This directory contains programs that are able to be used by the system(Linux), the administrator and non-privileged users. Examples of such programs would include cp, mv, rm, and other such commands/programs. In addition to programs it also contains the shells, like bash, csh, sh, and so on. Just as a side note, you should be aware that there is also a /usr/bin which also contains programs that the system, administrator, and non-privileged users can use. However, unlike those in /bin, these programs are not essential-meaning that you can do without them and not have any real problems. Some programs that are located in my /usr/bin are: g++, apt-get, javac, whoami, and acroread. Sure it would be a pain not having these programs, but the system would still run perfectly fine.

/boot

All of the system startup files and the kernel (vmlinuz) are located in this directory (also I would suggest reading the Wikipedia article on System.map, which is also stored in this directory). On Ubuntu, this is also where Grub (GRand Unified Boot loader) stored.  For those of you that are dual-booting here is something that might interest you.  When you start up your system you will normally see a list asking you which OS you want to enter.  This list normally contains the various Linux kernels along with Windows (or whatever OS you have on your computer).  If you would like to change the order these elements are presented along with other properties here is what you need to do.  cd /boot/grub then sudo gedit menu.lst (actually you can use whatever text editor you desire)  The file is pretty well documented so editing it is pretty straight forward.

/dev

All computers have hardware, and this is where the information on all your hardware is stored. Once again let me reiterate that EVERYTHING is a file (or directory but I don’t distinguish between them in this case). If you list all of the files here, you should find sda, sda1, sda2… which represent the partitions of you master drive (instead of sda you might have hda depending on your drive type). Also you might see a files /dev/cdrom and /dev/fd or (/dev/fd0). These represent your CDROM and floppy drive (if you have them that is, because really who still has a floppy drive?). Here is something “cool” that you should all try (don’t worry it won’t damage your computer. I have done it on mine if that makes you feel any better). The file /dev/dsp represents your speakers (or whatever sound output device you have). So anything written to this file will be redirected to your speakers and played for you to hear. Thus if you run cat ~/funfile.java > /dev/dsp you will hear what funfile.java “sounds like”, assuming that you have a file called funfile.java in your home directory. Pretty cool hu?

/etc

Finally, I will slightly discuss the /etc directory.  One overview that I read, described this directory as the Linux equivalent to the Control Panel in Windows.  Basically most of the important configuration files are located here.  There are a lot of important files here that have to do with system start up (one being /etc/rc.d which contains the startup scripts for the system). It is always a good idea to back up your system, but this file more than any other I would say should really be backed up. Doing so would save you a lot of headache later when you have to reconfigure your settings, because you reinstalled your system or somehow managed to lose your installation.

Well that’s all there is for part 2. Hope you will stick around for part 3.


On my First Script

July 15, 2009

Well as promised it is time to explain parts of my script. Well I shall start at the beginning.  The !#/bin/bash tell the OS where the interpretor for the script can be found. The following line is just a place where most of the work will be done.  This should actually be changed to cd ~ if I were planning on sharning this script (which I am).

Now for the more “interesting” aspects.

ls -a | grep “^\.” > temp

This line will first list all the fils found in a directory (ls -a). Then it will find those that begin with a ‘.’ (dot) and print them to a file called temp.  This is done through the use of grep “^\.” grep works with regx, and in the one used here it will match ‘phrases’ that begin with a ‘.’ (dot).  Pretty much grep can do a lot of things (or so I have read) but they rely on regx so needless to say I am currently working on learning regx.  Anyway back to the code. After this I do a search to find a file called .myPw, this is where the password will be stored.  So if the file doesn’t exist we shall create it, along with a password to place into it.

After this I basically use some basic loops to test the user’s input to see if it matches the password.  I won’t talk about the loop structure since 1: this isn’t a tutorial on bash, and 2: it is easy enough to figure out from just reading the code.  I won’t explain what echo does, if you don’t know just click on the man link at the top of this blog and then click on echo.  It’s actually a pretty “simple” command.

One last thing, I would like to point out that after making the file temp I deleted it once I no longer needed it. This turns out to be somewhat optinal (I’ll explain in a moment), but I think it’s just “polite” to delete temporary files you put on someone else’s system.  Now for why this is optional.  The way the code is set up, if there already exist a file called temp it will overwrite it.  If however I had used

ls -a | grep “^\.” >> temp

It would append the output to the end of the file (in which case who knows what was in there before and how much you will have to seach through while looking for .myPw).  So there is a BIG difference between > and >>, both direct output to a file but in differnt fashions.