Getting started with Android Development

Hey everyone,

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:

AVD and SDK in Eclipse

AVD and SDK in Eclipse

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:

Android Application Project Selection

Android Application Project Selection

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.

NewApp

 

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).

Configure

 

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.

Icon

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.

Activity

 

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.

Names

 

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 :

HelloWorld

 

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.

AVD

 

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.

NewAVD

 

You should now see your newly created virtual device in the AVD Manager window. Click it to select and then hit start.

AVDStart

 

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:

Run

 

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.

FirstApp

 

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,
Hunter J

Tagged , , , , , , , , . Bookmark the permalink.

26 Responses to Getting started with Android Development

  1. Robert says:

    thanks nice.. that was the easiest part.. but now comes the hardcore java stuff. that was the end for my career as android developer. ;)

    • Hunter_J says:

      Haha, I can understand your worries if you’ve never developed with java ( or any other language, really ). In the future I plan to be tackling a wide range of topics that should use the reader over time and experimentation to getting used to programming in Java. By no means do you need to be a brilliant java developer to make some cool and fun stuff in Android though.

      Thanks for taking the time to check the post out and comment. Feel free to follow calmlycoding on facebook or twitter if you think you might be interested in more beginner level tutorials ( though, not all my posts are android related ).

  2. Ira says:

    Exquisite guide.

    I look forward to future additions, as this is something I’ve meaning to dabble in.

    Please continue the great work!

    (As a side note, to get the Developer bundle to work, I had to drop the jdk’s bin folder inside of the eclipse folder. Creating this hierarchy-
    ~/eclipse/jre/bin (jdk bin folder goes here)

    • Hunter_J says:

      Ah, thanks for posting your way on getting that to work. You can also have eclipse point to the location of the jdk as well, that way your path variable doesn’t get messed up (if you’ve already set it up). I’m glad that you like the guide and due to the amazing response I’ve gotten on it I 100% intend to keep creating guides.

      • Ira says:

        Fantastic, I’ll be sure to check back frequently!

        Any ETA on part II?

        • Hunter_J says:

          If you have a twitter ( or facebook ) you can find calmlycoding on there and both are updated anytime I add a new post to the blog. I’m not so sure on an ETA for the next part, mainly because I haven’t decided exactly what all it will cover. I’m hoping to have it out by next Wednesday, but I’m keeping myself extremely busy so I don’t want to make any promises.

  3. Brendan says:

    Thanks so much for this tutorial. I have really wanted to get started with android developing for a while, and this has kicked me in the pants.

  4. dil says:

    any accompanying videos would be perfect
    great job sir

    • Hunter_J says:

      That’s the plan. A friend of mine runs the super popular youtube blog allaboutandroids and based on the tutorials that I make the plan is to have him whip up accompanying video guides. Thanks for checking in!

  5. Kay says:

    Hopefully more will come. I came across lots of tutorial websites but a number of them are pretty confusing. Hoping the rest will be in the same easy to read format :D

    • Hunter_J says:

      That’s the plan – I’ve already gotten the next one probably half done. There’s a lot of important basics to get through in the first few and while the basics aren’t generally that exciting, I’m hoping that the easy to read factor will teach what’s needed. I figure that people wanting to do the more advanced stuff will already know the basics either from here, somewhere else or teaching themselves ( as I did ). My biggest issue with pretty much all tutorials I came across when trying to learn was that they all seemed to be for people who already knew what they were doing, and that’s why I’m taking such an easy to read approach.

      I’m glad you liked it, and hope that the next few will also be as helpful and easy to get through.

  6. Name says:

    Can we get email subscription please?
    Would be nice to be alerted when a new part is up.

    Thanks.

    • Hunter_J says:

      I’m glad that you liked this post enough to want to know when there are more. That sounds like a reasonable request – currently calmlycoding’s twitter and Facebook profiles are updated every time I post new content to the blog. I will, however, look in to getting email subscriptions up and running. Thanks for the suggestion!

      • Name says:

        Thanks for the answer, indeed i like where this is going, most tutorials grow over my head to fast.
        I guess it is easy to skip some small step thinking they are meaningless when you’re doing this daily.

        Greetings.

        • Hunter_J says:

          The plan is to hopefully continue making tutorials that people who aren’t already established developers can keep up with. It seems most getting started tutorials assume that the reader already knows what they’re doing or uses unaccessible language. My hope is to make something accessible.

  7. Pingback: My Homepage

  8. Anon says:

    I had some issues with the emulator –
    “Failed to allocate memory: 8 This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information.”

    However, I fixed it by adjusting the RAM to 512, and it worked perfectly afterwards.

    Otherwise great tutorial! I really enjoyed it and I look forward to future posts!

    Thanks

  9. Pingback: Android Development – Getting Active: Part 1 - calmlyCoding

  10. Panton says:

    I do not understand how to actually get the plugins and what not from the adt bundle into juno. I have a progress picture of what I’ve done so far. http://puu.sh/2sP0G

    Thanks in advance!

    • Hunter_J says:

      I’m sorry about the delay in responding to you, as I said in my latest post, my world has been insanely busy the last little while.

      I believe that the package has changed a little bit since I wrote this; so if you’re still having issues, I’ll take a look at the current version and get back to you this weekend!

  11. whatsapp says:

    Thanks for a marvelous posting! I certainly enjoyed reading it, you’re a great author. I will make sure to bookmark your blog and definitely will come back in the foreseeable future. I want to encourage that you continue your great work, have a nice holiday weekend!

  12. Z says:

    Where is part 2?

    • Hunter_J says:

      Part two will come sometime within the next month – as my last real post said, I ended up being very unexpectedly busy.

      My course load has decreased somewhat though, so I’m hoping to be able to dedicate some time to this series again.

      Thanks for your interest and sorry about the delay.

Leave a Reply

Your email address will not be published. Required fields are marked *


7 × one =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>