Building Your Android Development Environment
In my article “Create an Android Development Environment,” I showed you how to install and configure an Android development environment for Eclipse on a Windows PC. I also included a link to the Android Hello World tutorial. A Hello World application is usually very simple and helps ensure you have the product installed by displaying a literal (usually “Hello World!”) on the screen, but it doesn’t have much utility beyond that point. This article will present an introductory application to serve the same purpose but with a little more meat to it that we can use in subsequent articles to build a true business application. It does assume that you’ve followed the previous article, but other than that it starts from scratch.
Create the Project
Start your Eclipse workbench. If you’ve followed my previous article, you’ll see an empty workbench. The first thing we need to do is create a project.
Creating a project is simple. Click on the File option of the main menu as shown in Figure 1, selecting first New/Project..., and, from the resulting dialog, Android Project. This will bring up a New Android Project wizard (shown in Figure 2). It has several fields to fill, but you only need a few to get started. As you learn more about Android development, you may take advantage of other values.
The Project Name is important; by default it tends to be how the application is known to the outside world, including on your phone (you can change that later, but I like to start simple). Hit Next and the second panel appears, allowing you to select the “Build Target,” which basically identifies the SDK version you’ll be using. The SDK version in turn determines which physical devices can install your application. I installed the Android 2.2 SDK because that’s the one that works on my phone; you may choose another. You’ll also see the Google APIs SDK; Google-enabled SDKs include some special APIs that work on Google-enabled phones. This primarily allows some very nifty map integration (see here). On the third page, enter your package name. Like all Java development, you need to have your own package space to make sure you don’t collide with other packages. I use com.pbd as my high-level package name, you should use your domain named reversed (typically com.mycompany).
After you’ve created the project, it’ll appear in the Package Explorer view. You can expand it as shown in Figure 3. There are two components of primary interest during this initial exploration into Android development: the .java file for the activity and the main.xml resource file in the layout folder. You can think of these as the RPG code and the display file DDS, respectively. And much like an RPG application, we’ll start with the display (we’ll return to the Java later). If you double-click on the main.xml, you’ll see the WYSIWYG Android display designer.
Search our new 2013 Buyer's Guide.
Web Exclusive | Rational enables development in multiplatform environments
Web Exclusive | Stretching the native Droid APIs for IBM i
E-Newsletter | Could cloud computing save you money?