Hangman Tutorial Lesson 1 – Creating the app

To see the final product (what it will look like when you are done with the tutorials), you can download the app from Google Play:

https://play.google.com/store/apps/details?id=com.famlinkup.hangman

I’m going to use Eclipse for my tutorial, so all screenshots and examples are given with Eclipse in mind. You can do it with other IDEs, but then you’re on your own to figure out how to do similar steps. Also, I assume you already have Java, Eclipse, and Android installed. If you need help with setting your computer up, see http://developer.android.com/sdk/installing/bundle.html for information. If you have trouble setting it up, look online for answers – there are already lots of sites to help you get your computer ready to develop for Android.

First, we need to create a project. Goto File -> New -> Other…

Eclipse New Project

Then select Android Application Project:

Create Android Application

Next, we need to fill in the details about your project. For Application Name and Project Name, enter “Hangman”. For package name, type in “com.famlinkup.hangman” (or any other unique package name of your choosing). For the different SDK’s, let me explain what they mean.

Android Project Details

Minimum Required SDK is the minimum version a device needs to install and run your app. So if you want older devices to run your app, choose as low a number as possible. However, keep in mind that the lower version you choose, the less features are available to your version. I usually choose Android 2.2 as my minimum version number because it usually has all the features I care about and practically all devices out there have at least version 2.2 installed (see here for a chart showing was percentage of people have what version).

Target SDK refers to what version you are using in developing and testing your app with. So if you have a Google Nexus 4 phone with 4.4 installed and you are using this device to test with, you would specify Android 4.4. Compiled with version specifies what version Eclipse will use to actually compile your code. You can set this your Minimum Required SDK version to avoid using features only available to later versions. However, Google advises you to use the latest SDK version available: “setting the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.”

Click on Next. We want to uncheck “Create custom launcher icon”, as we’ll update this in a later tutorial. Click Next again.

New Android Application Dialog

We want it to create an Activity by default, so leave “Create Activity” checked and select Blank Activity. We’ll go more into what an Activity represents later. Click Next.

Create Activity

On the next screen, we need to specify details about the Activity we are creating. Set the Activity Name to “MainActivity”, the Layout Name to “main” and leave the Fragment Layout Name as fragment_main. Finally, click on “Finish”.

Blank Activity

Your screen should now look like this, where you have a project on your Package Explorer named Hangman. You could also see another project called appcompat_v7 that is created for you. You won’t need to do worry about this project – just don’t delete it because your hangman app makes use of it.

2014-03-22 15_55_50-Java - Hangman_res_layout_fragment_main.xml - Eclipse

Now we are ready to run our application to see what it looks like. You have to choices when running your app – you can either run the built in emulator, or you can deploy and install your code to a device. I prefer the second because it’s much faster. To run it on your device, connect it to your computer with a USB cable. Again, there are many places that will walk you through how to setup your phone to allow for debugging (see http://developer.android.com/tools/device.html). Once you have your phone setup, click on the arrow next to the green play button, select “Run As” and select Android Application.

2014-03-22 16_00_37-Java - Hangman_res_layout_fragment_main.xml - Eclipse

To run the emulator, you need to set up a virtual device. To do this, click on the Android Virtual Device Manager. Click on new and set the properties you want for your virtual device. Then when you run your app, it will use your virtual device to emulate.

2014-03-22 17_24_50-Java - Hangman_res_layout_fragment_main.xml - Eclipse

Whether you run the emulator and download it onto your device, it should look something like this:

device-2014-03-22-160813

Congratulations, you have your first app that does nothing! In the next tutorial, we’ll actually start making it look more like hangman. Thanks!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s