The Android ports provided are based on my own development environment, which is based on Eclipse, as well as to my and the Android own structure. Still, everything inside the packages is plain adaptable source code, but I recommend to use Eclipse with the Android SDK as Google provides a plug-in for Eclipse which comes in handy if you start testing and especially debugging (which is normally a horrible work).
First of all you need to get all required tools. As mentioned this tutorial relies on Eclipse. Therefore, you have to download this wonderful IDE (and the de facto standard besides IntelliJ and Netbeans) from its page or through this link (at the moment of writing this tutorial, the current version is 3.5). On the download page you will see many Eclipse packages. Basically it is irrelevant which version you choose, but you have to know that each of them come with different plug-ins doing funny things. For example, the Eclipse Modeling Tools package comes with the whole package of plug-ins and software to support you in making MDA programs. I personally stick with the Eclipse IDE for Java EE Developers package, as everything else can be installed when needed. For your typical Android development even the Eclipse IDE for Java Developers would be enough, if you need to save space. Just download the preferred package from any mirror.
The second thing you need is, of course the Android SDK (currently in version 1.5r3). You can get it from here. Just choose your according operating system and everything is fine. As Eclipse it is used a zip package.
Note: If you do not have Java already installed, download it here and install it as it is a pre-requisite for Eclipse and Android.
Now that you have your Eclipse and your Android SDK you can “install” them. I put install in quotation marks because you do not really install any of them. Both are just zip packages you can extract anywhere you like. For me on Windows this would normally be c:Program Files. In result you would have a c:Program Fileseclipse and c:Program Filesandroid-sdk-windows-1.5_r3. That is basically the install part as the most important, to also comply to this “non-install” way is done during set up.
First of all, start up your Eclipse installation. Depending on your OS you should now how to do this. In the case of Windows just open eclipse.exe. Now Eclipse boots up and will ask you for your workspace. The workspace directory will be the location were all settings and projects for that workspace will be stored. It is totally up to you were to put it. Mine is c:workspaceandroid. I myself separate the overall workspace directory as I have different settings and projects for different circumstances. For instance you could make a jme, java, cdt etc. But it is up to you. When you selected your workspace Eclipse concludes its boot up and greets you with a nice picture (at least the very first time). You can close this “Welcome” and then you will see the overall Eclipse environment
I will not go over Eclipse in full as it provides MUCH and to describe everything would cost me about 20 years of my life. Good sources for such information is Google, the Eclipse site itself and for plugins Eclipse-Plugins. We will just continue with setting up Eclipse to be able to work with Android and therefore the lessons. We now would have to install the ADT plugin for Eclipse. It can be found here with an installation guide. I will continue here with a guide for Eclipse 3.5 as it is not listed there, but basically works the same. If you have Eclipse 3.3 or 3.4 please follow the instructions on the Android page.
Open Help -> Install New Software…. The window that pops up is to install plug-ins from local or web sources. Normally Eclipse plug-ins come through update sites, which allow a good “keep-up-to-date” functionality. In the Work with field you enter the Android update site for the ADT plug-in, which would be https://dl-ssl.google.com/android/eclipse/. Now press enter and Eclipse should start resolving what could installed from here in the window blow. You can also add the site as a permanent site through the Add button. Everything is the same, but you give away a name for that update site. When Eclipse has found the plug-ins you should see something similar to the image here. Check the whole Developer Tools so that DDMS and ADT are installed. Continue with Next, accept everything and follow the instructions. You will have to restart Eclipse afterwards (even on an OS that is not Windows ^^).
Now that your Eclipse is Android ready you would have to configure the plug-in. Therefore, open Window -> Preferences and select the Android branch. There point the SDK Location field to wherever you extracted the Android SDK. You should see something similar to the figure. I will not go over the rest of the points. Just have a look, most of them are self-explanatory. When you are finished just press OK and the location is stored.
The final step of configuration is to create an Android Virtual Device (AVD). This is basically the image the Emulator will run and install everything to. You can create an AVD with the command tools from Android or by using Eclipse. In Eclipse open Window -> Android AVD Manager. With this Virtual Device Manager you can create and delete AVDs. To create an AVD just enter a descriptive name, select the target of the image and the Skin. The target gives away compatibility preferences. The NeHe Android ports are all developed based on Android 1.5. If you want additional elements like Location-based services, choose the Google API target as it adds this functionality to a 1.5 framework. Just Create AVD and Finish.
Note: Maybe sometimes you want to keep your images clean and only for one project to not install every test on it. In this case you can create several Virtual Devices and select the according one in the Run Configurations under Run -> Run Configurations. Here you can set the target AVD for every Run instance you have.
Import and Begin!
Now that everything is set up you can start download the lessons and import these into your workspace. I provided the lessons as Eclipse projects therefore you can choose to import an existing project into the workspace. Just use the right mouse button in the Package Explorer -> Import -> General/Existing Projects into Workspace and choose either the archived package or if you extracted it already, the super folder to the extracted one. The single or multiple projects in the archive are listed in the window and you can select which to import to your workspace. It is automatically copied and added to it if you click finish.
Note: If the project should have errors (a red cross at the project name) first of all have a look at the “Problems” tab in the lower part. It should state what is wrong and sometimes how to fix it. Possibilities are to right click on the project and choose Android Tools -> Fix Project Properties. If this should not work, refresh the whole project with pressing F5 while the project root node is selected. If this does not work open Project -> Clean and clean all projects. This fires a full rebuild and sometimes resolves some errors. Sometimes you have to configure the Java location in the project properties. Open the properties by right clicking on the project root node. Here select “Java Build Path” and see if there are any problems.
Now, to run the lesson you just right click on the project root node and select Run As -> Android Application. Now, if everything has been configured correctly, Eclipse will start the Emulator and dock onto it to support debugging through the DDMS perspective. The DDMS perspective can be chosen from the upper right or if not already opened from the menu Window -> Open Perspective -> DDMS. The DDMS perspective is important as it allows you to inject for example GPS coordinates for testing purposes as well as it has the LogCat. The LogCat is basically the output window of all messages from the Emulator. For example, if you add a System.out.println() to your source code, it will appear here.
If you run the project, the Emulator should pop up, boot and start your project. You can basically do the same with the Emulator as with an Android device. The only big difference is that a press on the touchscreen is always a press with full amount of pressure. But, scrolling, menus, OpenGL, everything works fine. If you want to switch between vertical and horizontal without the need to set up a new AVD just press Ctrl+F11. Further information for working with Android and Eclipse can be found here, on the official site.
Note: You can leave the Emulator always opened! You do not need to close it every time you start a project with changes again. It will be automatically handled. Only sometimes after many, MANY starts my Emulator has some problems and cannot be connected anymore. But in general you do not need to restart it every time, as the initial boot may take some while. The very first boot of an AVD can take several minutes, so please be patient. If it does not start the project after about 5-10 minutes then try to exit and restart. Sometimes this helps.
If any questions should occur, please comment to this page.