Creating an Android Project

The first step is to create an Android project. An Android project contains the files that make up an application. To create a new project, first open Android Studio.

If this is your first time running Android Studio, you will see the Welcome dialog, as in Figure 1.3.

Figure 1.3  Welcome to Android Studio

Screenshot shows the welcome screen in Android Studio.

From the dialog, choose Start a new Android Studio project. If you do not see the dialog, you may have created projects before. In this case, choose FileNewNew Project....

You should see the New Project wizard (Figure 1.4). In the first screen of the wizard, enter GeoQuiz as the application name. For the company domain, enter android.bignerdranch.com. As you do this, you will see the generated package name change to com.bignerdranch.android.geoquiz. For the project location, you can use any location on your filesystem that you want.

Figure 1.4  Creating a new application

Figure shows New Project screen to Create New Project.

Notice that the package name uses a reverse DNS convention: The domain name of your organization is reversed and suffixed with further identifiers. This convention keeps package names unique and distinguishes applications from each other on a device and on Google Play.

Click Next. The next screen allows you to specify details about which devices you want to support. GeoQuiz will only support phones, so just check Phone and Tablet. Select a minimum SDK version of API 19: Android 4.4 (KitKat) (Figure 1.5). You will learn about the different versions of Android in Chapter 6.

Figure 1.5  Specifying device support

Screenshot shows specifying device support in Create New Project window.

Click Next.

In the next screen, you are prompted to choose a template for the first screen of GeoQuiz (Figure 1.6). You want the most basic template available. Choose Empty Activity and click Next.

(Android Studio updates regularly, so your wizard may look slightly different from what we are showing you. This is usually not a problem; the choices should be similar. If your wizard looks very different, then the tools have changed more drastically. Do not panic. Head to this book’s forum at forums.bignerdranch.com and we will help you navigate the latest version.)

Figure 1.6  Choosing a type of activity

Screenshot shows a selection of the type of activity in Create New Project window.

In the final dialog of this wizard, name the activity subclass QuizActivity (Figure 1.7). Notice the Activity suffix on the class name. This is not required, but it is an excellent convention to follow.

Figure 1.7  Configuring the new activity

Screenshot shows Customize the Activity screen.

Leave Generate Layout File checked. The layout name will automatically update to activity_quiz to reflect the activity’s new name. The layout name reverses the order of the activity name, is all lowercase, and has underscores between words. This naming style is recommended for layouts as well as other resources that you will learn about later.

If your version of Android Studio has other options on this screen, leave them as is. Click Finish. Android Studio will create and open your new project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.86.56