Wednesday, December 5, 2012

Getting Started (Part 3): Say Hello, Android!

This post is the last part of a three-part series of tutorials for getting started on Android development. Check out the previous entries here:

On our previous post, we've already set-up our Eclipse IDE and Android SDK. What's next? Well, let's get into the thick of things and develop our first Android application!

We'll be developing a simple application that shows "Hello, world!" to the user. As such, we'll name it HelloAndroid. It's boring and common, but then that's the only thing that's boring about Android development. Let's go!

GOING DOWN TO BUSINESS

After starting up Eclipse, we move right into action by creating a new Android Application Project. From our menu bar, click on File > New > Project..


A New Project dialog pops up. From here, expand the Android folder and select Android Application Project. Click Next.


For the next screen, we're presented with a good number of fields and options. I'll try breaking them down one by one:

Application Name
This will be used as the name of the application throughout the Android operating system. The entry will be seen under the application's icon in the Android application drawer, as well as entries in Google Play. This can be changed later in the Android Manifest file, but we'll get to that in a future post.

Project Name
This name will be used in your Eclipse workspace. This identifies the speficic Android project, since Eclipse does not allow duplicate project names for the same workspace.

Package Name
This is a set of words separated by dots that uniquely identify your application. Think of this as your unique application ID. Package names cannot be duplicated when publishing to Google Play, so make sure this one is unique to you and your application.

Minimum Required SDK
Select the minimum SDK that would be required of Android devices in order for your application to run. Devices running any SDK lower than this cannot search for your application in Google Play.

Target SDK
The SDK level that you develop your application on - meaning, this is the SDK level that you're application is known to work on, with the most features and the least issues.

Compile With
Usually targeted at the latest available API, or the API that your application has been tried to run on and successfully did.

Theme
This makes you select different themes for your initial application.


That about sums it up. In a nutshell, here are the entries we'll be using for this tutorial:
Application Name: Hello Android
Project Name: Hello Android Project
Package Name:com.helloandroid.sample
Minimum Required SDK: API 8
Target SDK: API 14
Compile with: API 17
Theme: Holo Light with Dark Action Bar

 (Make sure you've downloaded the appropriate API from the SDK Manager)

Click on Next.

For the Configure Project screen, click on Next.

On the Configure Launched Icon screen, you can just click on Next. Or you could play around with any icon, this won't really matter for now.

For Create Activity, make sure that Create Activity is ticked, and BlankActivity is selected. Click on Next.

On the New Blank Activity dialog, just click on Next. This is the part where we'll name our Activity file, but the pre-populated entries will do.

For the next screen, Eclipse will check for the presence of your dependencies. If they haven't been installed, just click on the Install/Upgrade then follow the next steps. After which, click on Finish.

You've just created a new Android Application Project! For the most part, all the needed files have been generated and prepared for us to display a Hello World! text to our application's users. If you did the above steps correctly, the left part of your Eclipse should look like this..



...while the main window of Eclipse would like something like,



RUNNING OUR APPLICATION

Since most of the world has already been done, what's left is for us to compile our application and have it run.

Basically, there are two ways to run your application. First is by having a physical Android device plugged into your machine and have the application run there right away. This would involve a few more configuration steps, but we won't be using this method for now.

The second way would be to run an Android Virtual Device, more commonly referred to as AVD. An AVD is basically an emulator that runs on your machine, no different than running a virtual machine like Mac OSX or Linux Ubuntu. If you're familiar with VMWare or VirtualBox, you'll find that the concept are very much alike.

For now, we'll go through the steps in running the AVD. Remember that icon we saw that led us to the SDK Manager? Now, we'll use the icon right beside it.

 

This opens up a dialog box,


 Click on New.., opening up another window. This time, just fill in the entries as shown below.


Click on OK. This will take you back to the AVD Manager window, but an additional entry will be present. Select this entry and click on Start.., then Launch.


Wait for the emulator to finish booting, and you should get something that looks like this:

 

Now that we have that running, let's go back to Eclipse. On our Project Manager window. (the one on the left), right-click on the project name (in this case, Hello Android Project) and select Run As > Android Application. This will automatically compile your application and run it on the AVD we just created. It can take a while to finish loading your application onto the AVD, but after it's done, it should look like this:


Congratulations! You've just run your first Android application!

Now, that's the east part. On the next posts, I'll take you through the code that allows us to run this application and show this text, as well as other things to keep in mind while developing for Android.

To check out the other posts of this series, click on the links below:

Monday, December 3, 2012

Getting Started (Part 2): Downloading the Android SDK

This is the second part of the series Getting Started. Previous editions can be found on the following links:

NOW that we've set up Eclipse in our development machines and made sure that it will run because we have installed Java, let's proceed to doing more Android-specific things - like, downloading the Android SDK.

RUNNING ECLIPSE



First of all, let's go ahead and open up our Eclipse installation. As with Part 1 of this series, double-click on eclipse.exe in the Eclipse folder. Once Eclipse has finished booting, you'll be asked to select your workspace - a folder on where to store your project files. Selecting the default is recommended here, as well as ticking on the "Use this as default.." checkbox.


Click on OK, and welcome to Eclipse!


INSTALLING THE ECLIPSE ADT PLUG-IN

Now it's time to get down and actually download the files we'll need for development.

On the menu bar, click on Help > Install New Software..., where a window will pop-up.



 Click on the Add.. button found near the top-right corner. In this succeeding window, put in Eclipse ADT in the Name field, and for the Location field, put in this link:


https://dl-ssl.google.com/android/eclipse/



Click on OK.

In this dialog box, check the box beside Developer Tools, then click on Next.

Just click on Next in the next window.

Accept the license agreements, and click on Finish.



After the download is complete, choose to restart Eclipse.



DOWNLOADING THE ANDROID SDK

After you've restarted Eclipse and proceeded to your workbench, you'll notice two new buttons on the icon pane just below the menu bar.


 Clicking on the Android SDK Manager will open a dialog box,


On the first run, SDK Manager will pre-select recommended packages for you to install - simply click on Install n packages... and wait for your download to finish.

Congratulations! You've just installed the Android SDK and are now ready to create Android applications!

On the next part of this series, I will take you through the steps to create a "Hello, Android!" application, as well as a few points while developing for Android in Eclipse.


Getting Started (Part 1): Setting Up Your Machine for Android Development

SO one day, you woke up and out of habit, you checked your smartphone for new messages and Facebook updates. Quite common, right? But what if you decided that the phone you were holding in your hand had so much capabilities that weren't utilized yet. You decide to take matters into your own hands, and proceed to learn Android development!

For this post, I'll walk you through setting up your machine so that you can start hacking away the next great Android application. Here's what you'll need:

  • Windows 7 (recommended)
  • Java Standard Edition 6
  • Eclipse
  • Android SDK
..and a good, stable internet connection.

PREPARING FOR JAVA
 
Most, if not all, Android developers are using Eclipse as the IDE for development - and for Eclipse to work on our Windows machines, we'll need to make sure the Java is installed. As of this writing, the latest Java Standard Edition available is Java SE 7, but Java SE 6 will work as well. You can hit up this link and download a copy appropriate to your machine:

http://www.oracle.com/technetwork/java/javase/downloads/jdk7u9-downloads-1859576.html



DOWNLOADING THE ECLIPSE IDE

  Truth be told, the Eclipse IDE is more a recommendation than a requirement. However, we will be using Eclipse because (1) Android recommends using Eclipse, and (2) the Android SDK was meant to run on the Eclipse IDE.

People often ask me which Eclipse should I download, since there are a few good versions available. As of this writing, the latest would be Eclipse Juno - I recommend the Classic version for it's easier to use and has all the features that we'll be using. Of course, you can just add other plug-ins if you wish. For now, hit up this link and download Eclipse Classic:

http://www.eclipse.org/downloads/ 



Make sure to use the appropriate bit-version for your Java compiler.


After you've finished this download, you'll be given an archive file. Use any archive extractor like WinZip or WinRAR to extract the files into a location on your machine. I recommend placing the extracted folder into your Documents folder - any location will do, just make sure to remember where you saved it in.


 Open the folder and double-click on eclipse.exe to run Eclipse for the first time.

That's it for this edition. On the next part, we'll run through the Eclipse IDE and guide ourselves to download the necessary files to begin coding for Android. See you!

Getting Started (Part 2): Downloading the Android SDK

Thursday, November 29, 2012

Mandatory First Post

Hi All!

To start things off, I would like to say thank Google and the Open Handset Alliance for bringing to us Android, an open-source OS for mobile phones and tablets. Since the first Android phone (T-Mobile G1) came out in 2008, Android has experienced growth like no other OS in history, and it is for this sane reason that I chose to learn Android Development.

Now, with a few years and a few applications published on Google Play (plus a perfect 1.0 for my Software Engineering class for an Android project), I have decided to start a tutorial blog for Android development, where I can share my experiences and share to you guys the great development experience of Android.

Let's start working!