Welcome to the first in a series of beginner android developer tutorials aimed at getting newcomers up and going on their own applications. This installment is designed to help you get eclipse and the android development tools installed so that you might get started on making your first killer app.
Before we begin with the content there are a few suggestions I’ll make before diving headlong into android development:
Programming is frequently very frustrating, especially early on. Be patient with yourself and understand that progress is progress.
If you don’t know anything about programming, you might want to take a java tutorial to learn the principle ideas. While this won’t be a necessity for anything we will cover, for further development I strongly suggest it.
Alright, now with all that preface stuff out of the way, let’s get down to business.
I’m not going to talk in depth on how to get your dev environment set up, as there are far too many operating systems to talk about getting set up and that alone could make series of posts. I WILL, however, point you in the right place to make sure you have all you need.
First, you need to make sure the Java JDK is installed. Oracle has a guide to get this set up here.
Second you’ll need to get Eclipse on your system. There IS a mobile development version of Eclipse, but I prefer to use the standard version. The most up to date version of Eclipse is Juno, and you can get it from the Eclipse site here. ( You’re looking for the Java IDE for Java EE Developers )
Thirdly, you’ll need the Android SDK ( Software Development Kit ), which Google has recently made into a bundle. Previously you had to download the Eclipse plugin separately from the SDK and ADT ( Android Development Tools ). Thankfully this is all taken care of by Google in the bundle that you can get here.
To ensure that the android SDK and all your development tools are installed correctly, let’s open up Eclipse. In your toolbar you should see the AVD ( Android Virtual Device ) and Android SDK icons. In the following image I’ve outlined them in a red box:
So NOW you should have everything you need to actually start your very first app. Normally, that would be enough for a whole blog post – but today we’re going to go one step further and actually create a super simple “Hello World” app in Eclipse.
To begin, go to File -> New -> Other. You’ll want to select Android Application Project inside the Android folder and click Next:
Next, we need to name our app. There are a lot of options here so here’s a quick description of each:
- Application Name – The name of your app that will appear in the app directory
- Project Name – The internal name that Eclipse will use, you can normally leave this as it’s assigned based on your Application Name
- Package Name – Packages are a Java convention that allows for better organization of code into like sections. A general rule of thumb is to make it a domain, but backwards.
- Minimum Required SDK – This sets the minimum version of Android that your app will run on. Later versions allow for use of different libraries that may only work on later API’s, so it’s normally best to create your app to be as backwards compatible as possible. As of the writing of this tutorial there is still a whopping 60% of active Android devices using android 2.2 – 3.0 so the lower you can manage your minimum required SDK, the more people will be able to use your app.
- Target SDK – The version of the SDK that you’re targeting. Normally you’ll select the most recent version.
- Compile With – The version of the SDK to compile with, again set it to be the most recent.
- Theme – Android layouts can come with predefined colour schemes. Just leave this as it is for now and hit next.
There’s nothing special on this next screen, just note that the two boxes are checked ( you can opt to uncheck these one future apps if you’d like, but we’ll keep them active for this version).
You’ll now see a screen to configure your Launcher Icon. This shows up because we kept the first option checked on the previous screen. The SDK gives you a few basic options to toy around with using text or clip art. You can also upload an image that you’ve already created and select it from your drive. For fun, I used the Text option and made my own. Feel free to toy around in here. When you’ve finished, hit next.
Now you’ll see the option to create an Activity. An activity in Android is synonymous with an action that happens in your app. For each thing that your app does, you’ll most likely have an activity and attached to each activity there will be a layout ( as we’ll see soon ). There are multiple layouts that we can choose here, but for now – let’s just choose BlankActivity and hit next.
Now you’ll see a screen that asks us to specify a few things:
- Activity Name, which is what our Java class will be called for this activity,
- Layout Name, the name of the .XML file which will be used for the layout attached to this activity
- Navigation Type, the type of navigation that will be used for this activity
Normally you’d want to adjust these to what you’d want for your app’s purposes to be more descriptive of the action that activity is going to fulfill – right now we’ll leave everything default and click Finish.
Great! now Eclipse will do a bunch of things and automatically create a file structure and a whole bunch of files/folders that your app is going to need. All the hard work is essentially done.
When Eclipse has finished creating everything for you, it’ll bring up a window with the layout for your activity_main layout that you told it to create. It should look something like this :
This is your Hello World app, your very first masterpiece. In later tutorials I’ll talk about how to start messing around with and actually doing stuff with this app, as well as explain a bit more about what’s happening. But that’s enough for one tutorial.
BUT WAIT! I want to run it! Fair enough, there are a few ways to run this app and see it in action. If you have an android device you’d like to see your app on, you’ll need to turn on USB debugging. You can find this option in your device’s menu – depending on the version of Android you have it will be in Applications -> Development( older versions ) or Settings ->Developer Options( JellyBean + ).
If you don’t have an Android device, never fear. Luckily when we installed the development tools, we also installed an emulator. Let’s set that up now.
Click the button that I’ve outlined in the image below which takes you to the Android Virtual Device Manager.
In the following window, select the “New” option. With the AVD manager, we can set up a ton of different android device emulators, whether it’s custom specifications or templates based on existing devices. Today, we’ll set up an emulator for the Galaxy Nexus. We’ll name it GNEX_JELLYBEAN_4.1.2 and set the Device to be the Galaxy Nexus (4.65″, 720 x 1280: xhdpi) and change the target API to API Level 16. Following that, change the CPU to MIPS, leave the rest as default and hit OK.
You should now see your newly created virtual device in the AVD Manager window. Click it to select and then hit start.
On the window that pops up, leave all the options default and then click Launch. Eclipse will then open up an emulator window and begin to load. Note that this does take a while with the default settings – there are ways to speed it up a bit, however. But today we’ll just deal with waiting.
When everything’s finally finished loading up you’ll have your very own virtual android device! Feel free to play around with the emulator and get the feel for it. I normally prefer to do my debugging on my physical android devices because they’re a lot less laggy than the emulator.
Now that you’ve either got your android device or emulator all set up, it’s time to launch!
Right click on your project in the file structure in Eclipse and select Run as -> Android Application:
Eclipse will then ask where you’d like to run your app, select either your AVD that you set up (GNEX_JELLYBEAN_4.1.2) or your physical device and click OK. Eclipse will then build your app, install it onto your device ( or emulator ) and start it.
And VOILA! Your very first app, up and running!
That’s everything that we’re going to cover in this first tutorial. We jumped over a lot of stuff, and the app that we made is super simple. However, with these foundations in place, we’ll now be able to jump into actually making our app DO something next time.
I’d love to hear from you and answer any questions that you might have about getting your first app up and going. Or, if you have suggestions for future tutorials or even just want to say thanks – leave a comment and I’ll get back to you. Thanks everyone!
Signing off for now,