How To Write Your First Google Android Application

Ads by Google

hello world 2 600x401   How To Write Your First Google Android ApplicationWant to know how to write Google Android apps? Most Android applications are written in Java – a relatively easy to learn, friendly language for new developers. Aside from the possibility some money, you could actually contribute to the Android community. If you’ve got innovative ideas and the drive to see them spread, the Android market is for you! Let’s get you started on your very first Android application design.

Before we get to how to write Google Android apps – first, a bit of overview. Android apps (much like almost any mobile app) are developed on a computer – PC or Mac (generally) – and then compiled and sent to the device for testing. If you don’t have an Android device yet, there are emulators that simulate an Android device on your computer, meaning that you can still develop an Android game or application without owning one.

Step One: Download & Installation

First download and install the latest version of the Java JDK. Do not use the 64-bit version as it may cause you issues later on. Instead install the x86 version, with the default options.

Second, get the Android SDK – make sure to install the 32-bit ADT-Bundle version for Windows, even if you have a 64-bit system. That’s because everyone ends up complaining about the 64-bit version’s compatibility issues.

Ads by Google

The Android application design bundle includes all the necessary components, including Eclipse. However, it’s not an installable file. You will unzip it to any directory desired. Keep in mind where you unzipped this file.

If you have any problems with Java, uninstall all versions and retry installation. If that fails, try the 64-bit version of the JDK and the ADT-Bundle, if you have a 64-bit system.

Step Two: Configure The ADT-Bundle

First, start Eclipse, which is located within your ADT-Bundle within the Eclipse folder. If you are prompted to locate the Android SDK, you’ll have to manually find it from within your downloaded ADT-Bundle. It’s in the SDK folder.

2013 06 02 21h42 24   How To Write Your First Google Android Application

Second, you’ll be prompted to set your workspace location — the default is good enough. If you have problems starting or configuring Eclipse, close Eclipse and delete your workspace, which is located wherever you placed it.

2013 06 02 23h27 56   How To Write Your First Google Android Application

Third, click on the Android SDK icon in your toolbar in the ADT-Bundle.

2013 06 02 23h40 08   How To Write Your First Google Android Application

You’ll be prompted to download additional material for the SDK. Download the following:

  • “Samples for the SDK”;
  • “Documentation for Android SDK”;
  • “Google APIs” for the 4.2 (API 17) package.

You might notice that you can also install material for older versions of Android. If you want, go nuts, but it will increase your download time and take up hard drive space. Next, click on “Install packages” in the lower-right hand side of the screen.

2013 06 02 23h40 59   How To Write Your First Google Android Application

Fourth, check for updates to Eclipse by selecting “Help” from menu bar and choosing “Check for updates”.

Step Three: Set Up The Android Virtual Device (AVD)

First, click on the AVD (Android virtual device manager)  in the toolbar of the ADT interface. This creates a virtual device that lets you test your apps.

2013 06 03 11h34 43   How To Write Your First Google Android Application

Second, you will configure the device in the following way:

  • Set “Device” as whatever smartphone you use. However, this is largely irrelevant and only refers to screen size. Because you will be emulating an Android device on your computer, if you have a smaller computer screen, you may want to choose a smaller vertical resolution handset.

2013 06 03 11h37 05   How To Write Your First Google Android Application

  • Set “Target” as Android 4.2 API Level 17.
  • Check the box “Use Host GPU”, which will use your system’s GPU to speed things up a bit.

2013 06 03 11h41 46   How To Write Your First Google Android Application

You may need to play around with the settings above, such as reducing the amount of RAM available to your emulator.

Third, you will choose the AVD from the list of existing devices and then hit the “Start” button in the right column. On the following pop-up menu, launch the device.

Don’t close the AVD once it launches, you will need it for the rest of this tutorial.

Step 4: Create a New Project

Navigate to ‘File -> New -> Android Project’.

After choosing to create a new Android application design project, you will be guided through several windows. Don’t worry about the content of these, you can simply choose the default value for all of them.

2013 06 03 13h53 03   How To Write Your First Google Android Application

However, for those of you interested in customizing the appearance of your app, there’s options to choose the Holo theme and Android launcher icon, as well as other options. However, these are cosmetic options. As long as you choose the correct SDK for the SDK that you downloaded, you’ll be OK.

2013 06 03 13h53 50   How To Write Your First Google Android Application

It will take several minutes to create the new project. You may want to grab a cup of coffee while you wait. After you get your coffee, here’s what you should see in the AVD window:

2013 06 03 12h20 52   How To Write Your First Google Android Application

Step 5: Configure The New Project

By default the new project contains the “Hello World” text. If you’ve ever programmed in Java (or most languages), one of the first projects that you work on is the ubiquitous “Hello World” application, which uses the Println(“Hello World”); to generate the text. However, the ADT-Bundle already includes this code — you will simply create a new file that will run within the AVD.

You will notice that the Eclipse window’s screen displays “Hello World”. You can choose to modify this text by manually clicking and dragging the words around the screen. Alternatively, once you’ve selected the text, you can modify the size, font and bold (and many other) characteristics.

To make the text bold, click on “Hello World”. In the right-side “Properties” panel, scroll down until you see “Text Style”. When you’re all finished making changes, save the file by clicking on the save icon in the toolbar up top.

2013 06 03 15h32 17   How To Write Your First Google Android Application

At this point, you are pretty much done building the app. Save it and go to the next step.

Step 6: Run Your Program

From the Package Explorer in the left-side of the screen, open up the src folder, then open the com.example.helloworld folder. Inside you will see the file “mainactivity.java”.

Next, select “mainactivity.java”.

Above your code, you’ll see a little green “Play” button (or navigate to ‘Run>Run‘). Click it. When a popup box asks you how to run the application, you’re going to tell it to run as an “Android Application”. It will prompt you to save changes; hit yes.

2013 06 03 18h03 35   How To Write Your First Google Android Application

Now you get to wait an eternity while your virtual device boots up. I’d recommend that you leave it open for the duration of your programming sprees, otherwise you’re going to spend more time watching the Android logo spin than you will watching your program freeze up. Just saying. Efficiency.

After everything’s done loading, your application should upload and start automatically. Which means that right after you “unlock” the device, you’ll be greeted with your first Android program.

2013 06 03 15h43 17   How To Write Your First Google Android Application

That’s it, congratulations! The task can be a bit daunting at first, and definitely confusing, but if you stick with it you won’t be disappointed. If you step back and think about it, we only did a few really major things, the rest was just the process of connecting the pieces to make everything work.

Are you interested in Android application design? Do you want to become an Android developer? Have you ever written an Android app, and if so, what did it do? As always I love getting feedback in the comments section. As someone who answered yes to the first question, I’m in the process of learning to adequately code for my Android device, so do you have any websites or pointers that would help me or a fellow Android newbie out?

Updates to the Android Development Platform

Recently, Google released a preview edition of Android Studio, the first of its kind. When the final copy releases, developers will have access to a purpose built development kit for the Android operating system, instead of modified development environments.

The technology will likely eventually supplant Eclipse, and other SDKs. However, it hasn’t receive a release yet, so until then, we are stuck with Eclipse.

Additional Android Programming Reading and Tutorials

I strongly suggest checking out Alexander Tushinky‘s Android programming tutorial course, from Kickstarter.

MakeUseOf published a guide on using MIT’s Android App Creator, which allows individuals without a background in programming to get started building Android apps. The App Creator has its own quirks and learning curve. It’s good to start with, although you will more than likely want to eventually study Java and other languages. Ryan did a quick guide to the Google version of the App Inventor, if you don’t feel like reading an e-book.

If you’re more interested in Android game, development, check out this article. And for those of you looking to read a discussion on the subject of easily programming for Android, check out our Answer section.

For those of you seeking additional coding lessons, Jessica wrote about three of the most important sources on the net for Java tutorials. I highly recommend visiting the TheNewBoston’s YouTube channel.

Ads by Google

36 Comments - Write a Comment

Reply

Steven Hope

Fantastic article! I was following using OSX but still managed it. Another example of why I love makeuseof.com. (My Hello World app http://twitpic.com/1g47pu)

Steven Hope

huh…oops. remove the ) from the url

Paul Bozzay

Thank you! Always great to hear someone found something useful. Love the pic ;)

Reply

Steven Hope

Fantastic article! I was following using OSX but still managed it. Another example of why I love makeuseof.com. (My Hello World app http://twitpic.com/1g47pu)

Reply

Mark O’Neill

As an Android owner, I can personally attest that the Android Market is completely full of junk. Yes, there are the good apps too but they are hard to find because they are drowned out by all the crap. Google should have some kind of review procedure in place, much like Apple does, to remove all the crap clogging up the system.

Chris

Which would completely miss the point of Android being Free, and negate any advantages over the iPhone.

Reply

Alex

Anyone else getting errors when trying to connect to the software site via eclipse?? removing the ‘s’ doesn’t make a difference.

Vinod

I’m facing the same trouble, can anyone help?

Scott

In order to do this you have to go to the “settings” on the left side and put a check mark in the “Force https//…” box.
Then it will be fine

Alex

sorry, i don’t see “settings” anywhere in eclipse

Paul Bozzay

You most likely have a firewall blocking the download–you’ve got two options.

You can configure Eclipse to use your web browser’s proxy settings, or download the package manually. Because the proxy settings option is a bit more difficult, here’s the second option:

http://developer.android.com/sdk/eclipse-adt.html#troubleshooting

See the part where it gives you the ADT package install .zip file, and follow steps 1-6 below that. Let me know if it works!

Reply

Scott

In order to do this you have to go to the “settings” on the left side and put a check mark in the “Force https//…” box.
Then it will be fine

Reply

Nevadascott

Thanks so much! this is a great way to get a start! Would like to see more!!!

Paul Bozzay

Thanks for the feedback; anything in particular you want to see?

Reply

PaulB2

You most likely have a firewall blocking the download–you’ve got two options.

You can configure Eclipse to use your web browser’s proxy settings, or download the package manually. Because the proxy settings option is a bit more difficult, here’s the second option:

http://developer.android.com/s

See the part where it gives you the ADT package install .zip file, and follow steps 1-6 below that. Let me know if it works!

Reply

kumarann

The step by step procedure has been explained in the greater way as started with welcome message “Hello Android” like Java programming introduction.
the wonderful option in android development is that everything will be available in open source. No need to pay for anything.
I want Android to be the number one in the World in mobile application in the nearest future.

Reply

kumarann

The step by step procedure has been explained in the greater way as started with welcome message “Hello Android” like Java programming introduction.
the wonderful option in android development is that everything will be available in open source. No need to pay for anything.
I want Android to be the number one in the World in mobile application in the nearest future.

Reply

Alex

Thank you for the help, unfortunately i still havent gotten it working. Eclipse claims there is no repository, and occasionally it will simply say “there are no categorized items.”

Paul Bozzay

I’ve looked everywhere and can’t find a solution for you. Your best bet might be to restart the process or try from another computer. Are you doing this on windows or mac?

You have to make sure you do the steps in order because some of them depend on each other to work.

Reply

Jeremy

Hey Paul, thanks for a great article, to at least to give me starting point but my question is- how do you write a app? Ive got some great ideas (well…in my mind atleast.) but I dont know how to write code for them. Is there a future article on this?

Paul Bozzay

You need to know Java Programming [at least some of it] to write apps using the method in this article. Plus, there are some differences in the framework and how things need to be written for an Android device as opposed to, say, a PC. There’s books out there covering what you need to know–but I’d be happy to give it a go in an article if you want.

Anything specific you want to see? I’d be happy to write another [related] article if there’s interest.

Reply

PaulB2

You need to know Java Programming [at least some of it] to write apps using the method in this article. Plus, there are some differences in the framework and how things need to be written for an Android device as opposed to, say, a PC. There’s books out there covering what you need to know–but I’d be happy to give it a go in an article if you want.

Anything specific you want to see? I’d be happy to write another [related] article if there’s interest.

Reply

PaulB2

I’ve looked everywhere and can’t find a solution for you. Your best bet might be to restart the process or try from another computer. Are you doing this on windows or mac?

You have to make sure you do the steps in order because some of them depend on each other to work.

Reply

Gary

I liked this article VERY MUCH. It got me all fired up about learning to program in Android. However, I wanted to save the article for future reference and I did not see a way to do this . Help!!

Aibek

The ShareThis bookmarklet at the end of the blog lets you save the
article to pretty much any social bookmarking website (del.icio.us) or
email it to yourself.

Aibek

Garymol

Thanks a lot!!
I was able to look for the bookmark you indicated and sent myself the article.

Reply

Aibek

The ShareThis bookmarklet at the end of the blog lets you save the
article to pretty much any social bookmarking website (del.icio.us) or
email it to yourself.

Aibek

Reply

Garymol

Thanks a lot!!
I was able to look for the bookmark you indicated and sent myself the article.

Reply

hari

Hey Paul, that was very useful article. I bought htc hero months back thinking that i would have some fun programming, but never got myself to kickstart it..Now that i have something to start from..lets see how it goes..

Aibek

Hey Hari

Let us know how it goes :-)

Aibek

Reply

Aibek

Hey Hari

Let us know how it goes :-)

Aibek

Reply

Goggletron

Thanks, this helped alot.

Reply

Sweetvani4u

hello every one!!!!
i have one problem, in android project if it have more than 1 activity than how to write project,
in one project we write all activity?, or write different project for every different activity?

Reply

Sweetvani4u

hello every one!!!!
i have one problem, in android project if it have more than 1 activity than how to write project,
in one project we write all activity?, or write different project for every different activity?

Reply

Marcel

Works great! Only thing to emphasize, the emulator really, really, really takes a damn long time to start. First you see “A d r o i d”, then after minutes the logo and minutes later the android desktop. So be patient trying the emulator out. Once started, keep it running otherwise you’ll need to wait and wait and wait again…

Your comment